Class UserAgent
- java.lang.Object
-
- fr.dyade.aaa.agent.Agent
-
- org.objectweb.joram.mom.proxies.UserAgent
-
- All Implemented Interfaces:
AgentMBean,Encodable,Serializable,ProxyAgentItf,UserAgentMBean
public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgentItf
TheUserAgentclass implements the MOM proxy behaviour, basically forwarding client requests to MOM destinations and MOM destinations replies to clients.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classUserAgent.HeartBeatTaskTimer task responsible for closing the connection if it has not sent any requests for the duration 'timeout'.(package private) classUserAgent.SharedCtxThis kind of SharedCts (LinkedHashMap) is well-suited to building LRU caches.static classUserAgent.UserAgentFactory
-
Field Summary
Fields Modifier and Type Field Description private ClientContextactiveCtxReference to the activeClientContextinstance.static StringARRIVAL_STATE_PREFIXprivate UserAgentArrivalStatearrivalStateCounter of message arrivals from topics.private WakeUpTaskcleaningTaskprivate Map<Integer,String>clientIDsMap contains the clientIDprivate Hashtable<Integer,ConnectionContext>connectionsTable that contains the user connections: - key =Integer(connection key) - value =private Map<Integer,ClientContext>contextsTable of the proxy'sClientContextinstances.(package private) static booleanDEBUGprivate AgentIddmqIdIdentifier of this proxy dead message queue,nullfor DMQ not set.private Hashtable<Integer,UserAgent.HeartBeatTask>heartBeatTasksprivate List<MessageInterceptor>interceptorsINprivate List<MessageInterceptor>interceptorsOUTthe in and out interceptors list.private List<Properties>interceptorsPropINprivate List<Properties>interceptorsPropOUTprivate intkeyCounterCounter of the connection keysprivate static Loggerloggerstatic StringMESSAGE_TABLE_PREFIXprivate MessageTablemessagesTableTable holding the subscriptions' messages.private List<ClientContext>modifiedClientContextsThe ClientContexts to be saved after a react.private List<ClientSubscription>modifiedClientSubscriptionsThe ClientSubscriptions to be saved after a react.(package private) StringmsgTxnameprivate intnbMaxMsgMaximum number of Message store in subscriptions (-1 set no limit).private longnbMsgsSentToDMQSinceCreationthe number of erroneous messages forwarded to the DMQprivate longperiodperiod to run the cleaning task, by default 60s.private Map<Xid,XACnxPrepare>recoveredTransactionsTable holding the recovered transactions branches.static StringREDELIVERY_DELAYprivate intredeliveryDelayThe redelivery delay use to wait before re-delivering messages after a deny.private static longserialVersionUIDdefine serialVersionUID for interoperabilityprivate Map<String,UserAgent.SharedCtx>sharedSubsTable holding theSharedCtxinstances.private PropertiessubsClientIDsKey: subscription name
Value: clientIDprivate Map<String,ClientSubscription>subsTableTable holding theClientSubscriptioninstances.private intthresholdThreshold above which messages are considered as undeliverable because constantly denied.private Map<AgentId,TopicSubscription>topicsTableTable holding theTopicSubscriptioninstances.private static Set<CCUID>validCCStatic collection referencing all valid context in the server.-
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 private intactiveCtxId()Returns the identifier of the active context.private voidaddInterceptor(String agentId, String agentName, String interceptorsKey, List<MessageInterceptor> interceptors, Properties prop, List<Properties> interceptorsProp)private voidaddNewActiveCtx(int key)protected static voidaddValidCC(ClientContext cc)voidagentFinalize(boolean lastTime)Finalizes the agent before it is garbaged.voidagentInitialize(boolean firstTime)(Re)initializes the agent when (re)loading.protected voidagentSave()Enables the sub-classes to save their state.protected voidcleanPendingMessages(long currentTime)voiddecode(Decoder decoder)Decodes the object.voiddelete()Permits this agent to destroy itself.private voiddeleteProxy(FwdAdminRequestNot not)This method deletes the proxy by notifying its connected clients, denying the non acknowledged messages, deleting the temporary destinations, removing the subscriptions.voiddeleteSubscriptionMessage(String subName, String msgId)Deletes a particular pending message in a subscription.private voiddeleteTemporaryDestination(AgentId destId)private voiddelivers(String subName, ClientSubscription sub)If the subscription is active, launching a delivery sequence.private voiddoFwd(AgentId from, AbstractReplyNot rep)Distributes the JMS replies to the appropriate reactions.private voiddoFwd(AgentId from, QueueMsgReply rep)Actually forwards aQueueMsgReplycoming from a destination as aConsumerMessagesdestinated to the requesting client.private voiddoFwd(AgentId from, TopicMsgsReply rep)Method implementing the proxy reaction to aTopicMsgsReply.private voiddoFwd(BrowseReply rep)Actually forwards aBrowseReplycoming from a destination as aQBrowseReplydestinated to the requesting client.private voiddoFwd(SubscribeReply rep)Forwards the topic'sSubscribeReplyas aServerReply.private voiddoReact(int key, AbstractJmsRequest request, CallbackNotification callbackNotification)Distributes the client requests to the appropriate reactions.private voiddoReact(int key, ActivateConsumerRequest req)private voiddoReact(int key, AddClientIDRequest req)Method implementing the reaction to aAddClientIDRequestinstance add the clientID value of a connection.private voiddoReact(int key, CnxCloseRequest req)The method closes a given context by denying the non acknowledged messages delivered to this context, and deleting its temporary subscriptions and destinations.private voiddoReact(int key, CnxConnectRequest req)Method implementing the reaction to aCnxConnectRequestrequesting the key of the active context.private voiddoReact(int key, CommitRequest req, CallbackNotification callbackNotification)private voiddoReact(int key, GetAdminTopicRequest req)Method implementing the reaction to aGetAdminTopicRequestrequesting the identifier of the local admin topic.private voiddoReact(AgentId from, ExceptionReply rep)Actually forwards anExceptionReplycoming from a destination as aMomExceptionReplydestinated to the requesting client.private voiddoReact(AgentId from, GetClientSubscriptions not)Used to get number of local subscribers to 'from'.private voiddoReact(AgentId from, ReconnectSubscribersNot not)Sends reconnection messages to one or more subscribers.private voiddoReact(UnknownAgent uA)Method implementing the JMS proxy reaction to anUnknownAgentnotification notifying that a destination does not exist or is deleted.private voiddoReact(AdminReplyNot reply)AnAdminReplyacknowledges the setting of a temporary destination; nothing needs to be done.private voiddoReact(FwdAdminRequestNot not)private voiddoReact(TopicDeliveryTimeNot not)Processes a delayed message ready to be delivered.private voiddoReact(CloseConnectionNot not)private voiddoReact(CloseConnectionNot2 not)private voiddoReact(GetConnectionNot not)private voiddoReact(OpenConnectionNot not)Registers and starts theUserConnection.private voiddoReact(ProxyRequestGroupNot not)private voiddoReact(RequestNot not)private voiddoReact(ResetCollocatedConnectionsNot not)private voiddoReact(ReturnConnectionNot not)Differs the reply because the connection key counter must be saved before the OpenConnectionNot returns.private voiddoReact(SendRepliesNot not)private voiddoReact(SendReplyNot not)Notification sent by local agents (destinations) indicating that the proxy can reply to a client.private voiddoReact(SyncReply not)Method implementing the JMS proxy reaction to aSyncReplynotification sent by itself, wrapping a reply to be sent to a client.private voiddoReact(AdminCommandRequest request, AgentId replyTo, String requestMsgId)private voiddoReact(ClearSubscription request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(DeleteSubscriptionMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(GetSubscriptionMessageIds request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(GetSubscriptionMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(GetSubscription request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(GetSubscriptions request, AgentId replyTo, String requestMsgId, String replyMsgId)private voiddoReact(CnxStartRequest req)Method implementing the proxy reaction to aCnxStartRequestrequesting to start a context.private voiddoReact(CnxStopRequest req)Method implementing the JMS proxy reaction to aCnxStopRequestrequesting to stop a context.private voiddoReact(ConsumerAckRequest req)Method implementing the JMS proxy reaction to aConsumerAckRequestacknowledging a message either on a queue or on a subscription.private voiddoReact(ConsumerCloseSubRequest req)Method implementing the JMS proxy reaction to aConsumerCloseSubRequestrequesting to deactivate a durable subscription.private voiddoReact(ConsumerDenyRequest req)Method implementing the JMS proxy reaction to aConsumerDenyRequestdenying a message either on a queue or on a subscription.private voiddoReact(ConsumerReceiveRequest req)Method implementing the proxy reaction to aConsumerReceiveRequestinstance, requesting a message from a subscription.private voiddoReact(ConsumerSetListRequest req)Method implementing the JMS proxy reaction to aConsumerSetListRequestnotifying the creation of a client listener.private voiddoReact(ConsumerSubRequest req)Method implementing the JMS proxy reaction to aConsumerSubRequestrequesting to subscribe to a topic.private voiddoReact(ConsumerUnsetListRequest req)Method implementing the JMS proxy reaction to aConsumerUnsetListRequestnotifying that a consumer listener is unset.private voiddoReact(ConsumerUnsubRequest req)Method implementing the JMS proxy reaction to aConsumerUnsubRequestrequesting to remove a subscription.private voiddoReact(SessAckRequest req)Method implementing the JMS proxy reaction to aSessAckRequestacknowledging messages either on a queue or on a subscription.private voiddoReact(SessCreateDestRequest req)Method implementing the JMS proxy reaction to aSessCreateDestRequestrequesting the creation of a destination.private voiddoReact(SessDenyRequest req)Method implementing the JMS proxy reaction to aSessDenyRequestdenying messages either on a queue or on a subscription.private voiddoReact(TempDestDeleteRequest req)Method implementing the JMS proxy reaction to aTempDestDeleteRequestrequest for deleting a temporary destination.private voiddoReact(XACnxCommit req)Method implementing the JMS proxy reaction to anXACnxCommitrequest committing the operations performed in a given transaction.private voiddoReact(XACnxPrepare req)Method implementing the JMS proxy reaction to anXACnxPreparerequest holding messages and acknowledgements produced in an XA transaction.private voiddoReact(XACnxRecoverRequest req)Reacts to aXACnxRecoverRequestrequest requesting the identifiers of the prepared transactions.private voiddoReact(XACnxRollback req)Method implementing the JMS proxy reaction to anXACnxRollbackrequest rolling back the operations performed in a given transaction.private voiddoReply(AbstractJmsReply reply)Method used for sending anAbstractJmsReplyback to an external client within the active context.private voiddoSetPeriod(long period)voidencode(Encoder encoder)Encodes the object.protected ClientContextgetClientContext(int ctxId)StringgetDMQId()Returns the default DMQ for subscription of this user.intgetEncodableClassId()Enables the sub classes not to implement this method.intgetEncodedSize()Returns the size of the encoded object.private <K,V>
KgetKeyByValue(Map<K,V> map, V value)private StringBuffergetMBeanName()intgetMessageTableConsumedMemory()Returns the amount of memory consumed by the message table.protected StringgetMsgTxname()intgetNbMaxMsg()Returns the default maximum number of message for the subscription of this user.longgetNbMsgsSentToDMQSinceCreation()Returns the number of erroneous messages forwarded to the DMQ since creation time of this proxy..longgetPeriod()Returns the period value of this queue, -1 if not set.intgetRedeliveryDelay()Gets the redelivery delay.private StringgetSubMBeanName(String name)String[]getSubscriptionNames()Returns the list of subscriptions for this user.intgetThreshold()Returns the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.private voidinitialize(boolean firstTime)(Re)initializes the proxy.static booleanisValidCC(AgentId ua, int ctxid)voidmodifiedClient(ClientContext cc)voidmodifiedSubscription(ClientSubscription cs)private voidpersistDeliveryTimeMessage(Message msg)private ProducerMessagesprocessInterceptors(int key, ProducerMessages pm)voidreact(AgentId from, Notification not)Overrides theAgentclassreactmethod for providing the JMS client proxy with its specific behaviour.protected voidreactToClientRequest(int key, AbstractJmsRequest request, CallbackNotification callbackNotification)Method processing clients requests.private voidreactToClientRequest(int key, ConsumerReceiveRequest req)Either forwards theConsumerReceiveRequestrequest as aReceiveRequestdirectly to the target queue, or wraps it and sends it to the proxy if destinated to a subscription.private voidreactToClientRequest(int key, ConsumerSetListRequest req)Either forwards theConsumerSetListRequestrequest as aReceiveRequestdirectly to the target queue, or wraps it and sends it to the proxy if destinated to a subscription.private voidreactToClientRequest(int key, JmsRequestGroup request)private voidreactToClientRequest(int key, ProducerMessages req, CallbackNotification callbackNotification)Forwards the messages sent by the client in aProducerMessagesrequest as aClientMessagesMOM request directly to a destination, and acknowledges them by sending aServerReplyback.private voidreactToClientRequest(int key, QBrowseRequest req)Forwards the client'sQBrowseRequestrequest as aBrowseRequestMOM request directly to a destination.private voidremoveInterceptor(String interceptorsKey, List<MessageInterceptor> interceptors, String classNames, List<Properties> interceptorsProp)protected static voidremoveValidCC(ClientContext cc)private voidreplaceInterceptorIN(String agentId, String agentName, Properties prop)private voidreplaceInterceptorOUT(String agentId, String agentName, Properties prop)private voidreplyToTopic(AdminReply reply, AgentId replyTo, String requestMsgId, String replyMsgId)private voidresetActiveCtx()private voidsaveModifiedClientContexts()private voidsaveModifiedClientSubscriptions()voidsendNot(AgentId to, Notification not)Sends a notification to the specified agent.voidsendToClient(int key, AbstractJmsReply reply)Sends a reply to the client connected through the specified connection.private voidsendToDMQ(Message msg, short messageError)private voidsetActiveCtx(int key)Updates the reference to the active context.private voidsetDmq(ClientMessages not)voidsetInterceptors(Properties prop)Only call in UserAgent creation.protected voidsetMsgTxName(Message msg)voidsetNbMaxMsg(int nbMaxMsg)Sets the maximum number of message for the subscription of this user.voidsetNoSave()Sets theupdatedfield tofalseso that the agent state is not saved after the current reaction; the field is set back totruefor the next reaction.voidsetPeriod(long period)Sets or unsets the period for this queue.voidsetRedeliveryDelay(int redeliveryDelay)Sets the redelivery delay.voidsetSave()Sets theupdatedfield totrueso that the agent state is saved after the current reaction.voidsetThreshold(int threshold)Sets the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.StringtoString()Returns a string representation of this user's proxy.private booleanupdateSubscriptionToTopic(AgentId topicId, int contextId, int requestId)Updates the proxy's subscription to a topic.private booleanupdateSubscriptionToTopic(AgentId topicId, int contextId, int requestId, boolean asyncSub)Updates the proxy's subscription to a topic.-
Methods inherited from class fr.dyade.aaa.agent.Agent
delete, delete, deploy, deploy, doAdminSyncNotification, getAgentId, getCommitTime, getId, getLogTopic, getName, getReactNb, getReactTime, hasName, incWorkInProgress, isAgentProfiling, isDeployed, isFixed, isUpdated, load, needToBeCommited, resetCommitTime, resetReactTime, resetTimer, save, sendTo, sendTo, sendTo, setAgentProfiling, setName
-
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.proxies.ProxyAgentItf
getId
-
Methods inherited from interface org.objectweb.joram.mom.proxies.UserAgentMBean
getName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
private static final Logger logger
-
DEBUG
static final boolean DEBUG
-
ARRIVAL_STATE_PREFIX
public static final String ARRIVAL_STATE_PREFIX
- See Also:
- Constant Field Values
-
MESSAGE_TABLE_PREFIX
public static final String MESSAGE_TABLE_PREFIX
- See Also:
- Constant Field Values
-
interceptorsOUT
private transient List<MessageInterceptor> interceptorsOUT
the in and out interceptors list.
-
interceptorsIN
private transient List<MessageInterceptor> interceptorsIN
-
interceptorsPropIN
private List<Properties> interceptorsPropIN
-
interceptorsPropOUT
private List<Properties> interceptorsPropOUT
-
period
private long period
period to run the cleaning task, by default 60s.
-
nbMsgsSentToDMQSinceCreation
private long nbMsgsSentToDMQSinceCreation
the number of erroneous messages forwarded to the DMQ
-
modifiedClientContexts
private transient List<ClientContext> modifiedClientContexts
The ClientContexts to be saved after a react.
-
modifiedClientSubscriptions
private transient List<ClientSubscription> modifiedClientSubscriptions
The ClientSubscriptions to be saved after a react.
-
REDELIVERY_DELAY
public static final String REDELIVERY_DELAY
- See Also:
- Constant Field Values
-
redeliveryDelay
private int redeliveryDelay
The redelivery delay use to wait before re-delivering messages after a deny.
-
dmqId
private AgentId dmqId
Identifier of this proxy dead message queue,nullfor DMQ not set.
-
threshold
private int threshold
Threshold above which messages are considered as undeliverable because constantly denied. This value is used as default value at subscription creation. 0 stands for no threshold, -1 for value not set (use default value).
-
nbMaxMsg
private int nbMaxMsg
Maximum number of Message store in subscriptions (-1 set no limit). This value is used as default value at subscription creation.
-
contexts
private Map<Integer,ClientContext> contexts
Table of the proxy'sClientContextinstances.Key: context identifier
Value: context
-
validCC
private static Set<CCUID> validCC
Static collection referencing all valid context in the server. It allows to avoid to reply to request from closed context (JORAM-281).
-
subsTable
private Map<String,ClientSubscription> subsTable
Table holding theClientSubscriptioninstances.Key: subscription name
Value: client subscription
-
sharedSubs
private transient Map<String,UserAgent.SharedCtx> sharedSubs
Table holding theSharedCtxinstances.Key: subscription name
Value: the shared context
-
subsClientIDs
private Properties subsClientIDs
Key: subscription name
Value: clientID
-
recoveredTransactions
private Map<Xid,XACnxPrepare> recoveredTransactions
Table holding the recovered transactions branches.Key: transaction identifier
Value:XACnxPrepareinstance
-
arrivalState
private UserAgentArrivalState arrivalState
Counter of message arrivals from topics.
-
topicsTable
private transient Map<AgentId,TopicSubscription> topicsTable
Table holding theTopicSubscriptioninstances.Key: topic identifier
Value: topic subscription
-
messagesTable
private transient MessageTable messagesTable
Table holding the subscriptions' messages.Key: message identifier
Value: message
-
activeCtx
private transient ClientContext activeCtx
Reference to the activeClientContextinstance. Be careful, do not update activeCtx, or activeCtxId, directly. Always used mthods below: resetActiveCtx, addNewActiveCtx and setActiveCtx.
-
connections
private transient Hashtable<Integer,ConnectionContext> connections
Table that contains the user connections: - key =Integer(connection key) - value =
-
heartBeatTasks
private transient Hashtable<Integer,UserAgent.HeartBeatTask> heartBeatTasks
-
keyCounter
private int keyCounter
Counter of the connection keys
-
cleaningTask
private transient WakeUpTask cleaningTask
-
msgTxname
transient String msgTxname
-
-
Constructor Detail
-
UserAgent
protected UserAgent(String name, boolean fixed, int stamp)
Used by the Encodable framework
-
UserAgent
public UserAgent()
Constructs aUserAgentinstance.
-
UserAgent
public UserAgent(String name, int stamp)
Creates a new user proxy.- See Also:
ConnectionManager
-
-
Method Detail
-
getPeriod
public long getPeriod()
Returns the period value of this queue, -1 if not set.- Specified by:
getPeriodin interfaceUserAgentMBean- Returns:
- the period value of this queue; -1 if not set.
-
setPeriod
public void setPeriod(long period)
Sets or unsets the period for this queue.- Specified by:
setPeriodin interfaceUserAgentMBean- Parameters:
period- The period value to be set or -1 for unsetting previous value.
-
getRedeliveryDelay
public int getRedeliveryDelay()
Gets the redelivery delay.- Specified by:
getRedeliveryDelayin interfaceUserAgentMBean- Returns:
- the redeliveryDelay
-
setRedeliveryDelay
public void setRedeliveryDelay(int redeliveryDelay)
Sets the redelivery delay.- Specified by:
setRedeliveryDelayin interfaceUserAgentMBean- Parameters:
redeliveryDelay- the redeliveryDelay to set
-
getDMQId
public String getDMQId()
Returns the default DMQ for subscription of this user.- Specified by:
getDMQIdin interfaceUserAgentMBean- Returns:
- the default DMQ for subscription of this user.
-
getThreshold
public int getThreshold()
Returns the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.- Specified by:
getThresholdin interfaceUserAgentMBean- Returns:
- the maximum number of message if set; -1 otherwise.
-
setThreshold
public void setThreshold(int threshold)
Sets the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.- Specified by:
setThresholdin interfaceUserAgentMBean- Parameters:
threshold- the threshold to set.
-
getNbMaxMsg
public int getNbMaxMsg()
Returns the default maximum number of message for the subscription of this user. If the limit is unset the method returns -1.- Specified by:
getNbMaxMsgin interfaceUserAgentMBean- Returns:
- the maximum number of message if set; -1 otherwise.
-
setNbMaxMsg
public void setNbMaxMsg(int nbMaxMsg)
Sets the maximum number of message for the subscription of this user.- Specified by:
setNbMaxMsgin interfaceUserAgentMBean- Parameters:
nbMaxMsg- the maximum number of message (-1 set no limit).
-
addValidCC
protected static void addValidCC(ClientContext cc)
-
removeValidCC
protected static void removeValidCC(ClientContext cc)
-
isValidCC
public static boolean isValidCC(AgentId ua, int ctxid)
-
activeCtxId
private final int activeCtxId()
Returns the identifier of the active context. Value -1 means that there's no active context.
-
resetActiveCtx
private void resetActiveCtx()
-
addNewActiveCtx
private void addNewActiveCtx(int key)
-
setActiveCtx
private void setActiveCtx(int key) throws StateExceptionUpdates the reference to the active context.- Parameters:
key- Key of the activated context.- Throws:
StateException- If the context has actually been closed or lost.
-
agentInitialize
public void agentInitialize(boolean firstTime) throws Exception(Re)initializes the agent when (re)loading.- Overrides:
agentInitializein classAgent- Parameters:
firstTime- true when first called by the factory- Throws:
Exception- unspecialized exception
-
agentFinalize
public void agentFinalize(boolean lastTime)
Finalizes the agent before it is garbaged.- Overrides:
agentFinalizein classAgent- Parameters:
lastTime- true when last called by the factory on agent deletion.
-
getMBeanName
private final StringBuffer getMBeanName()
-
getMessageTableConsumedMemory
public int getMessageTableConsumedMemory()
Description copied from interface:UserAgentMBeanReturns the amount of memory consumed by the message table.- Specified by:
getMessageTableConsumedMemoryin interfaceUserAgentMBean
-
react
public void react(AgentId from, Notification not) throws Exception
Overrides theAgentclassreactmethod for providing the JMS client proxy with its specific behaviour.A JMS proxy specifically reacts to the following notifications:
OpenConnectionNot
-
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.
-
doReact
private void doReact(AgentId from, GetClientSubscriptions not)
Used to get number of local subscribers to 'from'. This number is sent as an Admin reply.- Parameters:
from- should be a Topic agent ID.not- contains the original Admin not sent to 'from'.
-
doReact
private void doReact(AgentId from, ReconnectSubscribersNot not)
Sends reconnection messages to one or more subscribers.- Parameters:
from-not-
-
doSetPeriod
private void doSetPeriod(long period)
-
doReact
private void doReact(OpenConnectionNot not)
Registers and starts theUserConnection.
-
doReact
private void doReact(ReturnConnectionNot not)
Differs the reply because the connection key counter must be saved before the OpenConnectionNot returns.
-
doReact
private void doReact(GetConnectionNot not)
-
doReact
private void doReact(RequestNot not)
-
doReact
private void doReact(ProxyRequestGroupNot not)
-
doReact
private void doReact(CloseConnectionNot2 not)
-
doReact
private void doReact(CloseConnectionNot not)
-
doReact
private void doReact(ResetCollocatedConnectionsNot not)
-
doReact
private void doReact(SendRepliesNot not)
-
doReact
private void doReact(SendReplyNot not)
Notification sent by local agents (destinations) indicating that the proxy can reply to a client.- Parameters:
not-
-
sendNot
public void sendNot(AgentId to, Notification not)
Sends a notification to the specified agent.- Specified by:
sendNotin interfaceProxyAgentItf- Parameters:
to- the identifier of the recipient agentnot- the notification to send
-
sendToClient
public void sendToClient(int key, AbstractJmsReply reply)Sends a reply to the client connected through the specified connection.- Parameters:
key- the key of the connection the client is connected through.reply- the reply to send to the client.
-
setNoSave
public void setNoSave()
Description copied from class:AgentSets theupdatedfield tofalseso that the agent state is not saved after the current reaction; the field is set back totruefor the next reaction.
-
setSave
public void setSave()
Description copied from class:AgentSets theupdatedfield totrueso that the agent state is saved after the current reaction.
-
toString
public String toString()
Returns a string representation of this user's proxy.- Specified by:
toStringin interfaceAgentMBean- Specified by:
toStringin interfaceUserAgentMBean- Overrides:
toStringin classAgent- Returns:
- A string representation of this agent.
-
setInterceptors
public void setInterceptors(Properties prop) throws Exception
Only call in UserAgent creation.- Parameters:
prop- properties- Throws:
Exception
-
initialize
private void initialize(boolean firstTime) throws Exception(Re)initializes the proxy.- Parameters:
firstTime-- Throws:
Exception- If the proxy state could not be fully retrieved, leading to an inconsistent state.
-
reactToClientRequest
protected void reactToClientRequest(int key, AbstractJmsRequest request, CallbackNotification callbackNotification)Method processing clients requests.Some of the client requests are directly forwarded, some others are sent to the proxy so that their processing occurs in a transaction.
A
MomExceptionReplywrapping a DestinationException might be sent back if a target destination can't be identified.
-
reactToClientRequest
private void reactToClientRequest(int key, ProducerMessages req, CallbackNotification callbackNotification) throws RequestExceptionForwards the messages sent by the client in aProducerMessagesrequest as aClientMessagesMOM request directly to a destination, and acknowledges them by sending aServerReplyback.- Throws:
RequestException- The destination id is undefined
-
sendToDMQ
private void sendToDMQ(Message msg, short messageError)
-
setDmq
private void setDmq(ClientMessages not)
-
reactToClientRequest
private void reactToClientRequest(int key, ConsumerReceiveRequest req) throws RequestExceptionEither forwards theConsumerReceiveRequestrequest as aReceiveRequestdirectly to the target queue, or wraps it and sends it to the proxy if destinated to a subscription.- Throws:
RequestException- Undefined (null) destination
-
reactToClientRequest
private void reactToClientRequest(int key, ConsumerSetListRequest req) throws RequestExceptionEither forwards theConsumerSetListRequestrequest as aReceiveRequestdirectly to the target queue, or wraps it and sends it to the proxy if destinated to a subscription.- Throws:
RequestException- Undefined (null) destination
-
reactToClientRequest
private void reactToClientRequest(int key, QBrowseRequest req) throws RequestExceptionForwards the client'sQBrowseRequestrequest as aBrowseRequestMOM request directly to a destination.- Throws:
RequestException- Undefined (null) destination
-
reactToClientRequest
private void reactToClientRequest(int key, JmsRequestGroup request)
-
doReact
private void doReact(int key, AbstractJmsRequest request, CallbackNotification callbackNotification)Distributes the client requests to the appropriate reactions.The proxy accepts the following requests:
GetAdminTopicRequestCnxConnectRequestCnxStartRequestCnxStopRequestSessCreateTQRequestSessCreateTTRequestConsumerSubRequestConsumerUnsubRequestConsumerCloseSubRequestConsumerSetListRequestConsumerUnsetListRequestConsumerReceiveRequestConsumerAckRequestConsumerDenyRequestSessAckRequestSessDenyRequestTempDestDeleteRequestXACnxPrepareXACnxCommitXACnxRollbackXACnxRecoverRequest
A
JmsExceptReplyis sent back to the client when an exception is thrown by the reaction.
-
doReact
private void doReact(int key, GetAdminTopicRequest req) throws AccessExceptionMethod implementing the reaction to aGetAdminTopicRequestrequesting the identifier of the local admin topic.It simply sends back a
GetAdminTopicReplyholding the admin topic identifier.- Throws:
AccessException- If the requester is not an administrator.
-
doReact
private void doReact(int key, CnxConnectRequest req) throws DestinationExceptionMethod implementing the reaction to aCnxConnectRequestrequesting the key of the active context.It simply sends back a
ConnectReplyholding the active context's key.- Throws:
DestinationException- In case of a first administrator context, if the local administration topic reference is not available.
-
doReact
private void doReact(CnxStartRequest req)
Method implementing the proxy reaction to aCnxStartRequestrequesting to start a context.This method sends the pending
ConsumerMessagesreplies, if any.
-
doReact
private void doReact(CnxStopRequest req)
Method implementing the JMS proxy reaction to aCnxStopRequestrequesting to stop a context.This method sends a
ServerReplyback.
-
doReact
private void doReact(SessCreateDestRequest req) throws RequestException
Method implementing the JMS proxy reaction to aSessCreateDestRequestrequesting the creation of a destination.Creates the queue, sends it a
SetRightRequestfor granting WRITE access to all, and wraps aSessCreateTDReplyin aSyncReplynotification it sends to itself. This latest action's purpose is to preserve causality.Creates the topic, sends it a
SetRightRequestfor granting WRITE access to all, and wraps aSessCreateTDReplyin aSyncReplynotification it sends to itself. This latest action's purpose is to preserve causality.- Throws:
RequestException- If the destination could not be deployed.
-
doReact
private void doReact(ConsumerSubRequest req) throws StateException, RequestException
Method implementing the JMS proxy reaction to aConsumerSubRequestrequesting to subscribe to a topic.- Throws:
StateException- If activating an already active durable subscription.RequestException- If the subscription parameters are not correct.
-
doReact
private void doReact(ConsumerSetListRequest req) throws DestinationException
Method implementing the JMS proxy reaction to aConsumerSetListRequestnotifying the creation of a client listener.Sets the listener for the subscription, launches a delivery sequence.
- Throws:
DestinationException- If the subscription does not exist.
-
doReact
private void doReact(ConsumerUnsetListRequest req) throws DestinationException
Method implementing the JMS proxy reaction to aConsumerUnsetListRequestnotifying that a consumer listener is unset.- Throws:
DestinationException- If the subscription does not exist.
-
doReact
private void doReact(ConsumerCloseSubRequest req) throws DestinationException
Method implementing the JMS proxy reaction to aConsumerCloseSubRequestrequesting to deactivate a durable subscription.- Throws:
DestinationException- If the subscription does not exist.
-
doReact
private void doReact(ConsumerUnsubRequest req) throws DestinationException
Method implementing the JMS proxy reaction to aConsumerUnsubRequestrequesting to remove a subscription.- Throws:
DestinationException- If the subscription does not exist.
-
doReact
private void doReact(ConsumerReceiveRequest req) throws DestinationException
Method implementing the proxy reaction to aConsumerReceiveRequestinstance, requesting a message from a subscription.This method registers the request and launches a delivery sequence.
- Throws:
DestinationException- If the subscription does not exist.
-
doReact
private void doReact(SessAckRequest req)
Method implementing the JMS proxy reaction to aSessAckRequestacknowledging messages either on a queue or on a subscription.
-
doReact
private void doReact(SessDenyRequest req)
Method implementing the JMS proxy reaction to aSessDenyRequestdenying messages either on a queue or on a subscription.
-
doReact
private void doReact(ConsumerAckRequest req)
Method implementing the JMS proxy reaction to aConsumerAckRequestacknowledging a message either on a queue or on a subscription.
-
doReact
private void doReact(ConsumerDenyRequest req)
Method implementing the JMS proxy reaction to aConsumerDenyRequestdenying a message either on a queue or on a subscription.This request is acknowledged when destinated to a queue.
-
doReact
private void doReact(TempDestDeleteRequest req)
Method implementing the JMS proxy reaction to aTempDestDeleteRequestrequest for deleting a temporary destination.This method sends a
fr.dyade.aaa.agent.DeleteNotto the destination and acknowledges the request.
-
deleteTemporaryDestination
private void deleteTemporaryDestination(AgentId destId)
-
doReact
private void doReact(XACnxPrepare req) throws StateException
Method implementing the JMS proxy reaction to anXACnxPreparerequest holding messages and acknowledgements produced in an XA transaction.- Throws:
StateException- If the proxy has already received a prepare order for the same transaction.
-
doReact
private void doReact(XACnxCommit req) throws StateException
Method implementing the JMS proxy reaction to anXACnxCommitrequest committing the operations performed in a given transaction.This method actually processes the objects sent at the prepare phase, and acknowledges the request.
- Throws:
StateException- If committing an unknown transaction.
-
doReact
private void doReact(XACnxRollback req)
Method implementing the JMS proxy reaction to anXACnxRollbackrequest rolling back the operations performed in a given transaction.
-
doReact
private void doReact(XACnxRecoverRequest req) throws StateException
Reacts to aXACnxRecoverRequestrequest requesting the identifiers of the prepared transactions.Returns the identifiers of the recovered transactions, puts the prepared data into the active context for future commit or rollback.
- Throws:
StateException- If a recovered transaction branch is already present in the context.
-
doReact
private void doReact(SyncReply not)
Method implementing the JMS proxy reaction to aSyncReplynotification sent by itself, wrapping a reply to be sent to a client.
-
doReact
private void doReact(int key, CnxCloseRequest req)The method closes a given context by denying the non acknowledged messages delivered to this context, and deleting its temporary subscriptions and destinations.
-
doReact
private void doReact(int key, ActivateConsumerRequest req)
-
doReact
private void doReact(int key, CommitRequest req, CallbackNotification callbackNotification)
-
getKeyByValue
private <K,V> K getKeyByValue(Map<K,V> map, V value)
-
doReact
private void doReact(int key, AddClientIDRequest req) throws ExceptionMethod implementing the reaction to aAddClientIDRequestinstance add the clientID value of a connection.- Throws:
Exception
-
doFwd
private void doFwd(AgentId from, AbstractReplyNot rep)
Distributes the JMS replies to the appropriate reactions.JMS proxies react the following replies:
QueueMsgReplyBrowseReplySubscribeReplyTopicMsgsReplyExceptionReply
-
doFwd
private void doFwd(AgentId from, QueueMsgReply rep)
Actually forwards aQueueMsgReplycoming from a destination as aConsumerMessagesdestinated to the requesting client.If the corresponding context is stopped, stores the
ConsumerMessagesfor later delivery.
-
doFwd
private void doFwd(BrowseReply rep)
Actually forwards aBrowseReplycoming from a destination as aQBrowseReplydestinated to the requesting client.
-
doFwd
private void doFwd(SubscribeReply rep)
Forwards the topic'sSubscribeReplyas aServerReply.
-
getMsgTxname
protected final String getMsgTxname()
-
setMsgTxName
protected final void setMsgTxName(Message msg)
-
doFwd
private void doFwd(AgentId from, TopicMsgsReply rep)
Method implementing the proxy reaction to aTopicMsgsReply. This method allows the distribution of messages received from the topic to the different local subscriptions.
-
delivers
private final void delivers(String subName, ClientSubscription sub)
If the subscription is active, launching a delivery sequence.- Parameters:
subName-sub-
-
persistDeliveryTimeMessage
private final void persistDeliveryTimeMessage(Message msg)
-
doReact
private void doReact(TopicDeliveryTimeNot not)
Processes a delayed message ready to be delivered.- Parameters:
not-
-
doReact
private void doReact(AgentId from, ExceptionReply rep)
Actually forwards anExceptionReplycoming from a destination as aMomExceptionReplydestinated to the requesting client.If the wrapped exception is an
AccessExceptionthrown by aTopicas a reply to aSubscribeRequest, removing the corresponding subscriptions.
-
doReact
private void doReact(AdminReplyNot reply)
AnAdminReplyacknowledges the setting of a temporary destination; nothing needs to be done.
-
doReact
private void doReact(UnknownAgent uA)
Method implementing the JMS proxy reaction to anUnknownAgentnotification notifying that a destination does not exist or is deleted.If it notifies of a deleted topic, the method removes the corresponding subscriptions. If the wrapped request is messages sending, the messages are sent to the DMQ.
A
JmsExceptReplyis sent to the concerned requester.This case might also happen when sending a
ClientMessagesto a dead message queue. In that case, the invalid DMQ identifier is set to null.
-
doReact
private void doReact(FwdAdminRequestNot not)
-
doReact
private void doReact(AdminCommandRequest request, AgentId replyTo, String requestMsgId)
-
doReact
private void doReact(GetSubscriptions request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
getSubscriptionNames
public String[] getSubscriptionNames()
Returns the list of subscriptions for this user. Each subscription is identified by its unique 'symbolic' name.- Specified by:
getSubscriptionNamesin interfaceUserAgentMBean- Returns:
- The list of subscriptions for this user.
-
doReact
private void doReact(GetSubscriptionMessageIds request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
doReact
private void doReact(GetSubscription request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
doReact
private void doReact(GetSubscriptionMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
doReact
private void doReact(DeleteSubscriptionMessage request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
deleteSubscriptionMessage
public void deleteSubscriptionMessage(String subName, String msgId)
Deletes a particular pending message in a subscription. The subscription is identified by its unique name, the message is pointed out through its unique identifier.- Parameters:
subName- The subscription unique name.msgId- The unique message's identifier.
-
doReact
private void doReact(ClearSubscription request, AgentId replyTo, String requestMsgId, String replyMsgId)
-
replyToTopic
private void replyToTopic(AdminReply reply, AgentId replyTo, String requestMsgId, String replyMsgId)
-
doReply
private void doReply(AbstractJmsReply reply)
Method used for sending anAbstractJmsReplyback to an external client within the active context.- Parameters:
reply- The reply to send.
-
getClientContext
protected ClientContext getClientContext(int ctxId)
-
cleanPendingMessages
protected void cleanPendingMessages(long currentTime)
-
delete
public void delete()
Description copied from class:AgentPermits this agent to destroy itself. If necessary, this method should be overloaded to work properly.- Specified by:
deletein interfaceAgentMBean- Specified by:
deletein interfaceUserAgentMBean- Overrides:
deletein classAgent
-
deleteProxy
private void deleteProxy(FwdAdminRequestNot not)
This method deletes the proxy by notifying its connected clients, denying the non acknowledged messages, deleting the temporary destinations, removing the subscriptions.- Parameters:
not- the request.
-
updateSubscriptionToTopic
private boolean updateSubscriptionToTopic(AgentId topicId, int contextId, int requestId)
Updates the proxy's subscription to a topic.- Parameters:
topicId- Identifier of the topic to subscribe to.contextId- Identifier of the subscription context.requestId- Identifier of the subscription request.- Returns:
trueif aSubscribeRequesthas been sent to the topic.
-
updateSubscriptionToTopic
private boolean updateSubscriptionToTopic(AgentId topicId, int contextId, int requestId, boolean asyncSub)
Updates the proxy's subscription to a topic.- Parameters:
topicId- Identifier of the topic to subscribe to.contextId- Identifier of the subscription context.requestId- Identifier of the subscription request.asyncSub- asynchronous subscription request.- Returns:
trueif aSubscribeRequesthas been sent to the topic.
-
getNbMsgsSentToDMQSinceCreation
public long getNbMsgsSentToDMQSinceCreation()
Description copied from interface:UserAgentMBeanReturns the number of erroneous messages forwarded to the DMQ since creation time of this proxy..- Specified by:
getNbMsgsSentToDMQSinceCreationin interfaceUserAgentMBean- Returns:
- the number of erroneous messages forwarded to the DMQ.
-
processInterceptors
private ProducerMessages processInterceptors(int key, ProducerMessages pm)
-
addInterceptor
private void addInterceptor(String agentId, String agentName, String interceptorsKey, List<MessageInterceptor> interceptors, Properties prop, List<Properties> interceptorsProp) throws Exception
- Throws:
Exception
-
removeInterceptor
private void removeInterceptor(String interceptorsKey, List<MessageInterceptor> interceptors, String classNames, List<Properties> interceptorsProp) throws Exception
- Throws:
Exception
-
replaceInterceptorIN
private void replaceInterceptorIN(String agentId, String agentName, Properties prop) throws Exception
- Throws:
Exception
-
replaceInterceptorOUT
private void replaceInterceptorOUT(String agentId, String agentName, Properties prop) throws Exception
- Throws:
Exception
-
modifiedClient
public void modifiedClient(ClientContext cc)
- Specified by:
modifiedClientin interfaceProxyAgentItf
-
modifiedSubscription
public void modifiedSubscription(ClientSubscription cs)
- Specified by:
modifiedSubscriptionin interfaceProxyAgentItf
-
saveModifiedClientContexts
private void saveModifiedClientContexts()
-
saveModifiedClientSubscriptions
private void saveModifiedClientSubscriptions()
-
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 classAgent- 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.
-
-