Class Queue
- java.lang.Object
-
- fr.dyade.aaa.agent.Agent
-
- org.objectweb.joram.mom.dest.Destination
-
- org.objectweb.joram.mom.dest.Queue
-
- All Implemented Interfaces:
AgentMBean,Encodable,Serializable,DestinationMBean,QueueMBean
- Direct Known Subclasses:
AcquisitionQueue,AliasInQueue,AliasQueue,ClusterQueue,DistributionQueue,FtpQueue,SchedulerQueue
public class Queue extends Destination implements QueueMBean
TheQueueclass implements the MOM queue behavior, basically storing messages and delivering them upon clients requests.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueue.QueueFactory
-
Field Summary
Fields Modifier and Type Field Description static StringARRIVAL_STATE_PREFIXprotected QueueArrivalStatearrivalStateCounter of messages arrivals.(package private) intcloadprivate static booleanDEBUG(package private) static AgentIddefaultDMQIdStatic value holding the default DMQ identifier for a server.(package private) static intdefaultRedeliveryDelayStatic value holding the default redelivery delay for a server.(package private) static intdefaultThresholdStatic value holding the default threshold for a server.protected List<Message>delayedList of delayed messagesstatic StringDELIVERY_TABLE_PREFIXstatic StringDELIVERY_TIMEOUTProperty preventing unacceptable delivery times when a selector processes excessively long queues.private intdeliveryDelayThe delivery delay in milliseconds used to wait before delivering a message.protected QueueDeliveryTabledeliveryTableTable keeping the message deliveriesprivate longdeliveryTimeoutprivate longDFLT_DELIVERY_TIMEOUT(package private) longhcons(package private) longhprodstatic StringLENIENT_REDELIVERY_DELAYProperty allowing to delay the denied messages even if there are not considered 'redelivered' (see JMS specification).static StringLENIENT_UNDELIVERABLEProperty allowing to handle 'denied' messages as if they were considered 'redelivered' (see JMS specification).private booleanlenientRedeliveryDelayprivate booleanlenientUndeliverableprivate static Loggerlogger(package private) static Loggerlogmsgprotected List<Message>messagesList holding the messages before delivery.(package private) StringBuffermsgTxPrefix(package private) intmsgTxPrefixLengthprotected intnbExpirationsNumber of stored messages with an expiration date.protected intnbMaxMsgnb Max of Message store in queue (-1 no limit).protected longnbMsgsDeniedSinceCreationprivate booleanpause(package private) intploadprivate intpriorityCommon priority value.protected booleanreceivingtrueif the queue is currently handling a new received message.private intredeliveryDelayThe re-delivery delay in seconds use to wait before re-delivering messages after a deny.protected List<ReceiveRequest>requestsList holding the requests before reply or expiry.private booleansamePrioritiestrueif all the stored messages have the same priority.private static longserialVersionUIDdefine serialVersionUID for interoperabilityprivate booleansyncExceptionOnFullDestif true, throws an exception on sending message on full destination.private intthresholdThreshold above which messages are considered as undeliverable because constantly denied; 0 stands for no threshold, -1 for value not set.-
Fields inherited from class org.objectweb.joram.mom.dest.Destination
clients, dmqId, freeReading, freeWriting, nbMsgsDeliverSinceCreation, nbMsgsSentToDMQSinceCreation, READ, READWRITE, strbuf, strictCounters, task, temporary, WRITE
-
Fields inherited from class fr.dyade.aaa.agent.Agent
agentProfiling, emptyString, fixed, logmon
-
Fields inherited from interface fr.dyade.aaa.common.encoding.Encodable
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidabortReceiveRequest(AgentId from, AbortReceiveRequest not)private voidacknowledge(String msgId)protected voidacknowledgeRequest(AcknowledgeRequest not)Method implementing the reaction to anAcknowledgeRequestinstance, requesting messages to be acknowledged.voidaddClientMessages(ClientMessages clientMsgs, boolean throwsExceptionOnFullDest)Adds the client messages in the queue.(package private) voidaddDeliveryTimeMessage(Message msg, boolean throwsExceptionOnFullDest, boolean isHeader)Adds the specified message to the list of delayed message.protected booleanaddMessage(Message message, boolean throwsExceptionOnFullDest)Adds a message in the list of messages to deliver.protected voidagentSave()Enables the sub-classes to save their state.protected voidbrowseRequest(AgentId from, BrowseRequest not)Method implementing the queue reaction to aBrowseRequestinstance, requesting an enumeration of the messages on the queue.protected booleancheckDelivery(Message msg)Returns true if conditions are ok to deliver the message.voidcleanPendingMessage()Removes all messages that the time-to-live is expired.protected DMQManagercleanPendingMessage(long currentTime)Cleans the pending messages list.voidcleanWaitingRequest()Removes all request that the expiration time is expired.protected voidcleanWaitingRequest(long currentTime)Cleans the waiting request list.voidclear()Removes all pending messages.private voidclearQueue(AgentId replyTo, String requestMsgId, String replyMsgId)voiddecode(Decoder decoder)Decodes the object.private voiddeleteQueueMessage(DeleteQueueMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)protected voiddeliverMessages(int index)Actually tries to answer the pending "receive" requests.private DMQManagerdenyMessage(String msgid, boolean redelivered, DMQManager dmqManager)Denies the specified message.protected voiddenyRequest(AgentId from, DenyRequest not)Method implementing the reaction to aDenyRequestinstance, requesting messages to be denied.protected voiddoAdminSyncNotification(AgentId from, AdminSyncNotification not)Handling of AdminSyncNotification.protected voiddoClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest)Method specifically processing aClientMessagesinstance.protected voiddoDeleteNot(DeleteNot not)Method specifically processing afr.dyade.aaa.agent.DeleteNotinstance.private voiddoExportMessages(String dirpath, String selector, boolean binary)Exports all messages in the specified directory.protected voiddoRightRequest(AgentId user, int right)Method specifically processing aSetRightRequestinstance.protected voiddoUnknownAgent(UnknownAgent uA)Method specifically processing anUnknownAgentinstance.voidencode(Encoder encoder)Encodes the object.voidexportMessages(String dirpath, String selector, boolean binary)Exports all messages in the specified directory.protected voidfinalize(boolean last)Finalizes the destination before it is garbaged.protected ClientMessagesgetClientMessages(int nb, String selector, boolean remove)Get a client message containnbmessages.longgetConsumerLoad()Return the average consumer's load during last moments.static AgentIdgetDefaultDMQId()Static method returning the default DMQ identifier.static intgetDefaultRedeliveryDelay()Static method returning the default redelivery delay for a server.static intgetDefaultThreshold()Static method returning the default threshold.CompositeDatagetDelayedMessage(String msgId)Returns the description of a particular delayed message.intgetDelayedMessageCount()Returns the number of messages waiting for a delay.TabularDatagetDelayedMessages()Returns the description of all pending messages.intgetDeliveredMessageCount()Returns the number of messages delivered and waiting for acknowledge.intgetDeliveryDelay()Returns the Queue deliveryDelay in milliseconds.intgetEncodableClassId()Enables the sub classes not to implement this method.intgetEncodedSize()Returns the size of the encoded object.private static StringgetIdString(Message msg)CompositeDatagetMessage(String msgId)Returns the description of a particular pending message.TabularDatagetMessages()Returns the description of all pending messages.private List<Message>getMessages(int nb, String selector, boolean remove)get messages, if it's possible.List<? extends MessageView>getMessagesView()Only used from shell-mom MOMCommandsImpl.private MessagegetMomMessage(String msgId)protected StringBuffergetMsgTxPrefix()intgetNbMaxMsg()Returns the maximum number of message for the destination.longgetNbMsgsDeliverSinceCreation()Returns the number of messages delivered since creation time of this destination.longgetNbMsgsDeniedSinceCreation()Returns the number of messages denied since creation time of this destination.longgetNbMsgsReceiveSinceCreation()Returns the number of messages received since creation time of this destination.intgetPendingMessageCount()Returns the number of pending messages in the queue.longgetProducerLoad()Return the average producer's load during last moments.protected MessagegetQueueMessage(String msgId, boolean remove)Get mom message, delete if remove = true.private voidgetQueueMessage(GetQueueMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)private voidgetQueueMessageIds(AgentId replyTo, String requestMsgId, String replyMsgId)intgetRedeliveryDelay()Returns the delay in seconds use to wait before re-delivering messages after a deny.protected PropertiesgetStats()intgetThreshold()Returns the threshold value of this queue, -1 if not set.bytegetType()Returns the type of this destination: Queue or Topic.intgetWaitingRequestCount()Returns the number of waiting requests in the queue.voidhandleAdminRequestNot(AgentId from, FwdAdminRequestNot not)protected voidhandleExpiredNot(AgentId from, ExpiredNot not)protected voidinitialize(boolean firstTime)Initializes the destination.booleanisPause()booleanisSyncExceptionOnFullDest()protected booleanisUndeliverable(Message message)Returnstrueif a given message is considered as undeliverable, because its delivery count matches the queue's threshold, if any, or the server's default threshold value (if any).protected booleanisValidJMXAttribute(String attrName)This method allows to exclude some JMX attribute of getJMXStatistics method.private voidlogmsg(Level loggerLevel, Level logmsgLevel, String logMessage)Logs message either in logmsg if configured, or in logger.protected voidmessageDelivered(String msgId)call in deliverMessages just after forward(msg), overload this method to process a specific treatment.protected voidmessageRemoved(String msgId)call in deliverMessages just after a remove message (invalid), overload this method to process a specific treatment.(package private) voidprocessDeliveryTime(AgentId from, QueueDeliveryTimeNot not)voidreact(AgentId from, Notification not)Distributes the received notifications to the appropriate reactions.protected voidreceiveRequest(AgentId from, ReceiveRequest not)Method implementing the reaction to aReceiveRequestinstance, requesting a message.static voidsetDefaultRedeliveryDelay(int reDeliveryDelay)voidsetDeliveryDelay(int deliveryDelay)Sets the Queue deliveryDelay in milliseconds.protected voidsetMsgTxName(Message msg)voidsetNbMaxMsg(int nbMaxMsg)Sets the maximum number of message for the destination.voidsetPause(boolean pause)voidsetProperties(Properties properties, boolean firstTime)Configures anQueueinstance.voidsetRedeliveryDelay(int redeliveryDelay)Sets the delay in seconds use to wait before re-delivering messages after a deny.voidsetSyncExceptionOnFullDest(boolean syncExceptionOnFullDest)voidsetThreshold(int threshold)Sets or unsets the threshold for this queue.protected voidstoreMessage(Message msg, boolean throwsExceptionOnFullDest)Actually stores a message in the deliverables list.StringtoString()Returns a string representation of this destination.voidwakeUpNot(WakeUpNot not)wake up, and cleans the queue.-
Methods inherited from class org.objectweb.joram.mom.dest.Destination
agentFinalize, agentInitialize, clientMessages, delete, deleteNot, forward, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQAgentId, getDMQId, getJMXStatistics, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, getRights, handleDeniedMessage, interceptorsAvailable, isAdministrator, isFreeReading, isFreeWriting, isLocal, isReader, isWriter, postProcess, preProcess, processAdminCommand, processInterceptors, processPause, processSetRight, processStartHandler, processStopHandler, replyToTopic, requestGroupNot, setAdminId, setFreeReading, setFreeWriting, setPeriod, setRight, unknownAgent
-
Methods inherited from class fr.dyade.aaa.agent.Agent
delete, delete, deploy, deploy, getAgentId, getCommitTime, getId, getLogTopic, getName, getReactNb, getReactTime, hasName, incWorkInProgress, isAgentProfiling, isDeployed, isFixed, isUpdated, load, needToBeCommited, resetCommitTime, resetReactTime, resetTimer, save, sendTo, sendTo, sendTo, setAgentProfiling, setName, setNoSave, setSave
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.agent.AgentMBean
getAgentId, getCommitTime, getReactNb, getReactTime, isAgentProfiling, isFixed, resetCommitTime, resetReactTime, resetTimer, setAgentProfiling
-
Methods inherited from interface org.objectweb.joram.mom.dest.DestinationMBean
delete, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getName, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, isFreeReading, isFreeWriting, setFreeReading, setFreeWriting, setPeriod
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
logmsg
static final Logger logmsg
-
DELIVERY_TABLE_PREFIX
public static final String DELIVERY_TABLE_PREFIX
- See Also:
- Constant Field Values
-
ARRIVAL_STATE_PREFIX
public static final String ARRIVAL_STATE_PREFIX
- See Also:
- Constant Field Values
-
defaultDMQId
static AgentId defaultDMQId
Static value holding the default DMQ identifier for a server.
-
LENIENT_REDELIVERY_DELAY
public static final String LENIENT_REDELIVERY_DELAY
Property allowing to delay the denied messages even if there are not considered 'redelivered' (see JMS specification). Normally, a message is considered 'redelivered' only if it has been delivered and rejected by the client. So, Messages 'denied' due to an error in the delivery mechanism are immediately re-delivered. The default value is false.- See Also:
- Constant Field Values
-
lenientRedeliveryDelay
private boolean lenientRedeliveryDelay
-
LENIENT_UNDELIVERABLE
public static final String LENIENT_UNDELIVERABLE
Property allowing to handle 'denied' messages as if they were considered 'redelivered' (see JMS specification). Normally, a message is considered 'redelivered' only if it has been delivered and rejected by the client, in this case its delivery counter is incremented. Then, a message is handled as 'undeliverable' only if it has been delivered and rejected several times by the client (the maximum number of attempts is defined by the queue's 'threshold' property). This property allows to increment the message delivery counter even when the message has been 'denied' due to an error in the delivery mechanism. The default value is false.- See Also:
- Constant Field Values
-
lenientUndeliverable
private boolean lenientUndeliverable
-
DELIVERY_TIMEOUT
public static final String DELIVERY_TIMEOUT
Property preventing unacceptable delivery times when a selector processes excessively long queues. If the time taken to retrieve a message from the queue exceeds the allotted time, the queue returns null, as if no message satisfied the query. If the timeout is negative, the queue is infinite. The default value is -1.- See Also:
- Constant Field Values
-
DFLT_DELIVERY_TIMEOUT
private long DFLT_DELIVERY_TIMEOUT
-
deliveryTimeout
private long deliveryTimeout
-
threshold
private int threshold
Threshold above which messages are considered as undeliverable because constantly denied; 0 stands for no threshold, -1 for value not set.
-
defaultThreshold
static int defaultThreshold
Static value holding the default threshold for a server.
-
redeliveryDelay
private int redeliveryDelay
The re-delivery delay in seconds use to wait before re-delivering messages after a deny.
-
defaultRedeliveryDelay
static int defaultRedeliveryDelay
Static value holding the default redelivery delay for a server.
-
deliveryDelay
private int deliveryDelay
The delivery delay in milliseconds used to wait before delivering a message. If set the resulting delay is the max between this value and the message property.
-
pause
private boolean pause
-
samePriorities
private boolean samePriorities
trueif all the stored messages have the same priority. Note:messageslist is ordered by priorities, so we could test if first and last message have the same priority.
-
nbExpirations
protected int nbExpirations
Number of stored messages with an expiration date.
-
priority
private int priority
Common priority value.
-
deliveryTable
protected transient QueueDeliveryTable deliveryTable
Table keeping the message deliveries
-
arrivalState
protected transient QueueArrivalState arrivalState
Counter of messages arrivals.
-
requests
protected List<ReceiveRequest> requests
List holding the requests before reply or expiry.
-
receiving
protected transient boolean receiving
trueif the queue is currently handling a new received message.
-
nbMsgsDeniedSinceCreation
protected long nbMsgsDeniedSinceCreation
-
nbMaxMsg
protected int nbMaxMsg
nb Max of Message store in queue (-1 no limit).
-
hprod
long hprod
-
hcons
long hcons
-
pload
int pload
-
cload
int cload
-
msgTxPrefix
transient StringBuffer msgTxPrefix
-
msgTxPrefixLength
transient int msgTxPrefixLength
-
syncExceptionOnFullDest
private boolean syncExceptionOnFullDest
if true, throws an exception on sending message on full destination.
-
-
Constructor Detail
-
Queue
public Queue()
Creates a queue.
-
Queue
protected Queue(String name, boolean fixed, int stamp)
Creates a queue with a specified stamp. It is used by the Encodable framework as the default constructor allocates a new stamp.- Parameters:
name- Name of topic;fixed- If true, topic is fixed in memory.stamp- Specific stamp for resulting agent.
-
-
Method Detail
-
getThreshold
public int getThreshold()
Returns the threshold value of this queue, -1 if not set.- Specified by:
getThresholdin interfaceQueueMBean- Returns:
- the threshold value of this queue; -1 if not set.
-
setThreshold
public void setThreshold(int threshold)
Sets or unsets the threshold for this queue.- Specified by:
setThresholdin interfaceQueueMBean- Parameters:
threshold- The threshold value to be set (-1 for unsetting previous value).
-
getDefaultThreshold
public static int getDefaultThreshold()
Static method returning the default threshold.
-
getDefaultDMQId
public static AgentId getDefaultDMQId()
Static method returning the default DMQ identifier.
-
getRedeliveryDelay
public final int getRedeliveryDelay()
Returns the delay in seconds use to wait before re-delivering messages after a deny.- Specified by:
getRedeliveryDelayin interfaceQueueMBean- Returns:
- the reDeliveryDelay
-
setRedeliveryDelay
public final void setRedeliveryDelay(int redeliveryDelay)
Sets the delay in seconds use to wait before re-delivering messages after a deny.- Specified by:
setRedeliveryDelayin interfaceQueueMBean- Parameters:
redeliveryDelay- the reDeliveryDelay to set
-
getDefaultRedeliveryDelay
public static final int getDefaultRedeliveryDelay()
Static method returning the default redelivery delay for a server.
-
setDefaultRedeliveryDelay
public static final void setDefaultRedeliveryDelay(int reDeliveryDelay)
-
getDeliveryDelay
public final int getDeliveryDelay()
Returns the Queue deliveryDelay in milliseconds.- Specified by:
getDeliveryDelayin interfaceQueueMBean- Returns:
- the DeliveryDelay
-
setDeliveryDelay
public final void setDeliveryDelay(int deliveryDelay)
Sets the Queue deliveryDelay in milliseconds.- Specified by:
setDeliveryDelayin interfaceQueueMBean- Parameters:
deliveryDelay- the deliveryDelay to set
-
isPause
public boolean isPause()
- Specified by:
isPausein interfaceQueueMBean
-
setPause
public void setPause(boolean pause)
- Specified by:
setPausein interfaceQueueMBean
-
setProperties
public void setProperties(Properties properties, boolean firstTime) throws Exception
Configures anQueueinstance.- Overrides:
setPropertiesin classDestination- Parameters:
properties- The initial set of properties.- Throws:
Exception
-
react
public void react(AgentId from, Notification not) throws Exception
Distributes the received notifications to the appropriate reactions.- Overrides:
reactin classDestination- Parameters:
from- agent sending notificationnot- notification to react to- Throws:
Exception
-
agentSave
protected void agentSave() throws IOExceptionDescription copied from class:AgentEnables the sub-classes to save their state.- Overrides:
agentSavein classAgent- Throws:
IOException- if any error occurs.
-
cleanWaitingRequest
public final void cleanWaitingRequest() throws ExceptionRemoves all request that the expiration time is expired. Be careful,this method is part of the Queue MBean interface, it can be called outside the reactions of the engine thread. In order to avoid synchronization issues we should avoid direct manipulation of requests list (see JORAM-372, JORAM-373).- Specified by:
cleanWaitingRequestin interfaceQueueMBean- Throws:
ExceptionInterruptedException
-
cleanWaitingRequest
protected void cleanWaitingRequest(long currentTime)
Cleans the waiting request list. Removes all request that the expiration time is less than the time given in parameter.- Parameters:
currentTime- The current time.
-
getWaitingRequestCount
public final int getWaitingRequestCount()
Returns the number of waiting requests in the queue.- Specified by:
getWaitingRequestCountin interfaceQueueMBean- Returns:
- The number of waiting requests.
-
getDelayedMessageCount
public final int getDelayedMessageCount()
Returns the number of messages waiting for a delay.- Specified by:
getDelayedMessageCountin interfaceQueueMBean- Returns:
- The number of messages waiting for a delay.
-
getType
public byte getType()
Description copied from class:DestinationReturns the type of this destination: Queue or Topic.- Specified by:
getTypein interfaceDestinationMBean- Specified by:
getTypein classDestination- Returns:
- the type of this destination.
- See Also:
DestinationConstants.TOPIC_TYPE,DestinationConstants.QUEUE_TYPE,DestinationConstants.TEMPORARY
-
cleanPendingMessage
public final void cleanPendingMessage() throws ExceptionRemoves all messages that the time-to-live is expired. Be careful,this method is part of the Queue MBean interface, it can be called outside the reactions of the engine thread. In order to avoid synchronization issues we should avoid direct manipulation of messages list (see JORAM-372, JORAM-373).- Specified by:
cleanPendingMessagein interfaceQueueMBean- Throws:
ExceptionInterruptedException
-
cleanPendingMessage
protected DMQManager cleanPendingMessage(long currentTime)
Cleans the pending messages list. Removes all messages which expire before the date given in parameter.- Parameters:
currentTime- The current time.- Returns:
- A
DMQManagerwhich contains the expired messages.nullif there wasn't any.
-
getPendingMessageCount
public final int getPendingMessageCount()
Returns the number of pending messages in the queue.- Specified by:
getPendingMessageCountin interfaceQueueMBean- Returns:
- The number of pending messages.
-
getDeliveredMessageCount
public final int getDeliveredMessageCount()
Returns the number of messages delivered and waiting for acknowledge.- Specified by:
getDeliveredMessageCountin interfaceQueueMBean- Returns:
- The number of messages delivered.
-
getNbMsgsDeniedSinceCreation
public final long getNbMsgsDeniedSinceCreation()
Returns the number of messages denied since creation time of this destination.- Specified by:
getNbMsgsDeniedSinceCreationin interfaceQueueMBean- Returns:
- the number of messages delivered since creation time.
-
getNbMsgsDeliverSinceCreation
public long getNbMsgsDeliverSinceCreation()
Description copied from class:DestinationReturns the number of messages delivered since creation time of this destination. It includes messages all delivered messages to a consumer, already acknowledged or not.- Specified by:
getNbMsgsDeliverSinceCreationin interfaceDestinationMBean- Overrides:
getNbMsgsDeliverSinceCreationin classDestination- Returns:
- the number of messages delivered since creation time.
-
getNbMsgsReceiveSinceCreation
public long getNbMsgsReceiveSinceCreation()
Description copied from class:DestinationReturns the number of messages received since creation time of this destination.- Specified by:
getNbMsgsReceiveSinceCreationin interfaceDestinationMBean- Specified by:
getNbMsgsReceiveSinceCreationin classDestination- Returns:
- the number of messages received since creation time.
-
getNbMaxMsg
public final int getNbMaxMsg()
Returns the maximum number of message for the destination. If the limit is unset the method returns -1.- Specified by:
getNbMaxMsgin interfaceQueueMBean- Returns:
- the maximum number of message for subscription if set; -1 otherwise.
-
setNbMaxMsg
public void setNbMaxMsg(int nbMaxMsg)
Sets the maximum number of message for the destination.- Specified by:
setNbMaxMsgin interfaceQueueMBean- Parameters:
nbMaxMsg- the maximum number of message (-1 set no limit).
-
initialize
protected void initialize(boolean firstTime) throws ExceptionInitializes the destination.- Specified by:
initializein classDestination- Parameters:
firstTime- true when first called by the factory- Throws:
Exception
-
finalize
protected void finalize(boolean last)
Finalizes the destination before it is garbaged.- Specified by:
finalizein classDestination- Parameters:
last- true if the destination is deleted
-
toString
public String toString()
Returns a string representation of this destination.- Specified by:
toStringin interfaceAgentMBean- Specified by:
toStringin interfaceDestinationMBean- Overrides:
toStringin classAgent- Returns:
- a string representation of this destination.
-
wakeUpNot
public void wakeUpNot(WakeUpNot not)
wake up, and cleans the queue.- Specified by:
wakeUpNotin classDestination
-
getProducerLoad
public long getProducerLoad()
Return the average producer's load during last moments.- Specified by:
getProducerLoadin interfaceQueueMBean
-
getConsumerLoad
public long getConsumerLoad()
Return the average consumer's load during last moments.- Specified by:
getConsumerLoadin interfaceQueueMBean
-
isValidJMXAttribute
protected boolean isValidJMXAttribute(String attrName)
This method allows to exclude some JMX attribute of getJMXStatistics method. It excludes.- Overrides:
isValidJMXAttributein classDestination- Parameters:
attrName- name of attribute to test.- Returns:
- true if the attribute is a valid one.
-
receiveRequest
protected void receiveRequest(AgentId from, ReceiveRequest not) throws AccessException
Method implementing the reaction to aReceiveRequestinstance, requesting a message.This method stores the request and launches a delivery sequence.
- Throws:
AccessException- If the sender is not a reader.
-
browseRequest
protected void browseRequest(AgentId from, BrowseRequest not) throws AccessException
Method implementing the queue reaction to aBrowseRequestinstance, requesting an enumeration of the messages on the queue.The method sends a
BrowseReplyback to the client. Expired messages are sent to the DMQ.- Throws:
AccessException- If the requester is not a reader.
-
acknowledgeRequest
protected void acknowledgeRequest(AcknowledgeRequest not)
Method implementing the reaction to anAcknowledgeRequestinstance, requesting messages to be acknowledged.
-
acknowledge
private void acknowledge(String msgId)
-
denyRequest
protected void denyRequest(AgentId from, DenyRequest not)
Method implementing the reaction to aDenyRequestinstance, requesting messages to be denied.This method denies the messages and launches a delivery sequence. Messages considered as undeliverable are sent to the DMQ.
-
denyMessage
private DMQManager denyMessage(String msgid, boolean redelivered, DMQManager dmqManager)
Denies the specified message.- Parameters:
msgid- The identifier of message to deny.redelivered- True if the message has been denied from user.dmqManager- The DMQManager if it exists, null otherwise.- Returns:
- The DMQManager if it exists, null otherwise.
-
logmsg
private void logmsg(Level loggerLevel, Level logmsgLevel, String logMessage)
Logs message either in logmsg if configured, or in logger.- Parameters:
loggerLevel-logmsgLevel-logMessage-
-
abortReceiveRequest
protected void abortReceiveRequest(AgentId from, AbortReceiveRequest not)
-
handleAdminRequestNot
public void handleAdminRequestNot(AgentId from, FwdAdminRequestNot not)
-
getQueueMessageIds
private void getQueueMessageIds(AgentId replyTo, String requestMsgId, String replyMsgId)
-
getQueueMessage
private void getQueueMessage(GetQueueMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
deleteQueueMessage
private void deleteQueueMessage(DeleteQueueMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
clear
public void clear()
Removes all pending messages.- Specified by:
clearin interfaceQueueMBean
-
doRightRequest
protected void doRightRequest(AgentId user, int right)
Method specifically processing aSetRightRequestinstance.When a reader is removed, and receive requests of this reader are still on the queue, they are replied to by an
ExceptionReply.- Specified by:
doRightRequestin classDestination- Parameters:
user- The user about right modification.right- The right modification.
-
doClientMessages
protected void doClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest) throws AccessException
Method specifically processing aClientMessagesinstance.This method stores the messages and launches a delivery sequence. This method is used when ClientMessages comes from a JMS client and/or LB notification in ClusterQueue (May be we should use addClienMessages). It is also used in old deprecated JMS bridge.
- Specified by:
doClientMessagesin classDestination- Throws:
AccessException
-
addDeliveryTimeMessage
void addDeliveryTimeMessage(Message msg, boolean throwsExceptionOnFullDest, boolean isHeader) throws AccessException
Adds the specified message to the list of delayed message.- Parameters:
msg- The message to add.throwsExceptionOnFullDest- if true, can throws an exception if destination is full.isHeader- If true, only save the message header (the message has already been saved).- Throws:
AccessException
-
processDeliveryTime
void processDeliveryTime(AgentId from, QueueDeliveryTimeNot not) throws AccessException
- Throws:
AccessException
-
doUnknownAgent
protected void doUnknownAgent(UnknownAgent uA)
Method specifically processing anUnknownAgentinstance.The specific processing is done when a
QueueMsgReplywas sent to a requester which does not exist anymore. In that case, the messages sent to this requester and not yet acknowledged are marked as "denied" for delivery to an other requester, and a new delivery sequence is launched. Messages considered as undeliverable are removed and sent to the DMQ.- Specified by:
doUnknownAgentin classDestination
-
doDeleteNot
protected void doDeleteNot(DeleteNot not)
Method specifically processing afr.dyade.aaa.agent.DeleteNotinstance.ExceptionReplyreplies are sent to the pending receivers, and the remaining messages are sent to the DMQ and deleted.- Specified by:
doDeleteNotin classDestination
-
getMsgTxPrefix
protected final StringBuffer getMsgTxPrefix()
-
setMsgTxName
protected final void setMsgTxName(Message msg)
-
storeMessage
protected final void storeMessage(Message msg, boolean throwsExceptionOnFullDest) throws AccessException
Actually stores a message in the deliverables list.- Parameters:
msg- The message to store.throwsExceptionOnFullDest- true, can throws an exception on sending message on full destination- Throws:
AccessException
-
isSyncExceptionOnFullDest
public boolean isSyncExceptionOnFullDest()
- Returns:
- the syncExceptionOnFullDest
-
setSyncExceptionOnFullDest
public void setSyncExceptionOnFullDest(boolean syncExceptionOnFullDest)
- Parameters:
syncExceptionOnFullDest- the syncExceptionOnFullDest to set
-
addMessage
protected final boolean addMessage(Message message, boolean throwsExceptionOnFullDest) throws AccessException
Adds a message in the list of messages to deliver. This method take care of the message priority if needed.- Parameters:
message- the message to add.throwsExceptionOnFullDest- true, can throws an exception on sending message on full destination- Returns:
- true if the message has been added. false if the queue is full.
- Throws:
AccessException- If syncExceptionOnFullDest and the queue isFull
-
getClientMessages
protected ClientMessages getClientMessages(int nb, String selector, boolean remove)
Get a client message containnbmessages. Only used in ClusterQueue.- Parameters:
nb- number of messages returned in ClientMessage.selector- jms selectorremove- delete all messages returned if true- Returns:
- ClientMessages (contains nb Messages)
-
getMessages
private List<Message> getMessages(int nb, String selector, boolean remove)
get messages, if it's possible.- Parameters:
nb- Maximum number of messages to return, if -1 returns all messages.selector- JMS selector.remove-- Returns:
- List of mom messages.
-
getQueueMessage
protected Message getQueueMessage(String msgId, boolean remove)
Get mom message, delete if remove = true.- Parameters:
msgId- message identificationremove- if true delete message- Returns:
- mom message
-
getMessage
public CompositeData getMessage(String msgId) throws Exception
Returns the description of a particular pending message. The message is pointed out through its unique identifier.- Specified by:
getMessagein interfaceQueueMBean- Parameters:
msgId- The unique message's identifier.- Returns:
- the description of the message.
- Throws:
Exception- See Also:
MessageJMXWrapper
-
getMessages
public TabularData getMessages() throws Exception
Returns the description of all pending messages.- Specified by:
getMessagesin interfaceQueueMBean- Returns:
- the description of the message.
- Throws:
Exception- See Also:
MessageJMXWrapper
-
getMessagesView
public List<? extends MessageView> getMessagesView()
Only used from shell-mom MOMCommandsImpl.
-
getDelayedMessage
public CompositeData getDelayedMessage(String msgId) throws Exception
Returns the description of a particular delayed message. The message is pointed out through its unique identifier.- Specified by:
getDelayedMessagein interfaceQueueMBean- Parameters:
msgId- The unique message's identifier.- Returns:
- the description of the message.
- Throws:
Exception- See Also:
MessageJMXWrapper
-
getDelayedMessages
public TabularData getDelayedMessages() throws Exception
Returns the description of all pending messages.- Specified by:
getDelayedMessagesin interfaceQueueMBean- Returns:
- the description of the message.
- Throws:
Exception- See Also:
MessageJMXWrapper
-
deliverMessages
protected void deliverMessages(int index)
Actually tries to answer the pending "receive" requests.The method may send
QueueMsgReplyreplies to clients.- Parameters:
index- Index where starting to "browse" the requests.
-
checkDelivery
protected boolean checkDelivery(Message msg)
Returns true if conditions are ok to deliver the message. This method must be overloaded in subclasses. Be careful only the message header is accessible.
-
messageDelivered
protected void messageDelivered(String msgId)
call in deliverMessages just after forward(msg), overload this method to process a specific treatment.
-
messageRemoved
protected void messageRemoved(String msgId)
call in deliverMessages just after a remove message (invalid), overload this method to process a specific treatment.
-
isUndeliverable
protected boolean isUndeliverable(Message message)
Returnstrueif a given message is considered as undeliverable, because its delivery count matches the queue's threshold, if any, or the server's default threshold value (if any).
-
addClientMessages
public void addClientMessages(ClientMessages clientMsgs, boolean throwsExceptionOnFullDest) throws AccessException
Adds the client messages in the queue. This method is used when messages does not come from a JMS Client, for example for AcquisitionQueue, AliasQueue and AliasInQueue.- Parameters:
clientMsgs- client message notification.throwsExceptionOnFullDest- true, can throws an exception on sending message on full destination- Throws:
AccessException
-
handleExpiredNot
protected void handleExpiredNot(AgentId from, ExpiredNot not)
-
getStats
protected Properties getStats()
- Specified by:
getStatsin classDestination
-
exportMessages
public void exportMessages(String dirpath, String selector, boolean binary) throws Exception
Exports all messages in the specified directory. Options? filtrage? Format?- Specified by:
exportMessagesin interfaceQueueMBean- Parameters:
dirpath-selector-quiet-- Throws:
ExceptionInterruptedException
-
doAdminSyncNotification
protected void doAdminSyncNotification(AgentId from, AdminSyncNotification not)
Handling of AdminSyncNotification. Currently only the EXPORT command is handled.- Overrides:
doAdminSyncNotificationin classAgent- Parameters:
from-not-
-
doExportMessages
private void doExportMessages(String dirpath, String selector, boolean binary) throws IOException
Exports all messages in the specified directory. Be careful, this method needs to be called from an agent reaction.- Throws:
IOException
-
getEncodableClassId
public int getEncodableClassId()
Description copied from class:AgentEnables the sub classes not to implement this method.- Specified by:
getEncodableClassIdin interfaceEncodable- Overrides:
getEncodableClassIdin classAgent- Returns:
- -1
-
getEncodedSize
public int getEncodedSize() throws ExceptionDescription copied from class:AgentReturns the size of the encoded object.- Specified by:
getEncodedSizein interfaceEncodable- Overrides:
getEncodedSizein classDestination- Returns:
- the size of the encoded object
- Throws:
Exception- if an error occurs
-
encode
public void encode(Encoder encoder) throws Exception
Description copied from class:AgentEncodes the object.- Specified by:
encodein interfaceEncodable- Overrides:
encodein classDestination- Parameters:
encoder- the encoder- Throws:
Exception- if an error occurs
-
-