Purpose: Define the implementation of the abstract RemoteConnection for JMS.
Description: Executing commands implementation of RemoteConnection is done via JMS Publisher. Using a single TopicConnection for both publishing and subscribing would allow subscriber to ignore messages sent through the same TopicConnection - and therefore allow JMSTopicRemoteConnection to ignore messages that it has itself published. Unfortunately J2EE doesn't allow that: J2EE spec. (J2EE.6.6 in v1.4) states: "The following methods may only be used by application components executing in the application client container: javax.jms.Session method setMessageListener ... Application components in the web and EJB containers must not attempt to create more than one active (not closed) Session object per connection." Because of these restrictions a) two JMSTopicRemoteConnection are required - one for publishing (external) and another one for listening (local); b) listening should be done using subscriber.receive() in an infinite loop in a separate thread, that's why the class implements Runnable interface. c) publishing connection (external) could be used concurrently to send messages, so it cannot use the same publisher/session/topicConnection Instead, it will store the TopicConnectionFactory and use it to create connections when executeCommandInternal is called (much like DatabaseAccessor when an external pool is used)
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | |
| private TopicPublisher | |
| protected TopicSubscriber | |
| protected Topic | |
| protected TopicConnection | |
| protected TopicConnectionFactory | |
| protected TopicSession | |
| public static long |
| Access | Constructor and Description |
|---|---|
| public | JMSTopicRemoteConnection(RemoteCommandManager rcm, TopicConnectionFactory topicConnectionFactory, Topic topic, boolean isLocalConnectionBeingCreated, boolean reuseJMSTopicPublisher)
INTERNAL: Constructor creating either a local or external connection. |
| public | JMSTopicRemoteConnection(RemoteCommandManager rcm)
Creates local connections that do not use a TopicConnection or TopicSession, useful only for processing already received JMS messages |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | areAllResourcesFreedOnClose()
INTERNAL:
Indicates whether all the resources used by connection are freed after close method returns.
|
| protected void | closeInternal()
Implements abstract org. |
| protected void | createDisplayString()
INTERNAL:
Used for debug logging
|
| protected Object | executeCommandInternal(Object command)
Implements abstract org. |
| public TopicPublisher | |
| public TopicSubscriber | |
| public Topic | |
| public TopicConnection | |
| public TopicConnection | |
| public TopicSession | |
| public boolean | |
| protected String | |
| public void | |
| public void | run()
Implements java. |
| public void | setPublisher(TopicPublisher publisher)
INTERNAL: set the TopicPublisher to be used when this RemoteConnection executes a command. |
| public void | setSuscriber(TopicSubscriber subscriber)
INTERNAL: set the TopicSubscriber on a local RemoteConnection for reading JMS messages when this runnable connection is started in a thread. |
| public void | |
| public void | |
| public void | setTopicConnectionFactory(TopicConnectionFactory topicConnectionFactory)
INTERNAL: Set the TopicConnectionFactory, which is used if the publisher is not set to obtain the TopicConnection, TopicSession and TopicPublisher |
| public void | setTopicSession(TopicSession topicSession)
INTERNAL: set the TopicSession to be used when this RemoteConnection executes a command if the publisher is also set. |
| protected boolean | Returns: boolean |
| isLocal | back to summary |
|---|---|
| protected boolean isLocal | |
| publisher | back to summary |
|---|---|
| private TopicPublisher publisher | |
| subscriber | back to summary |
|---|---|
| protected TopicSubscriber subscriber | |
| topic | back to summary |
|---|---|
| protected Topic topic | |
| topicConnection | back to summary |
|---|---|
| protected TopicConnection topicConnection | |
| topicConnectionFactory | back to summary |
|---|---|
| protected TopicConnectionFactory topicConnectionFactory | |
| topicSession | back to summary |
|---|---|
| protected TopicSession topicSession | |
| WAIT_ON_ERROR_RECEIVING_JMS_MESSAGE | back to summary |
|---|---|
| public static long WAIT_ON_ERROR_RECEIVING_JMS_MESSAGE | |
| JMSTopicRemoteConnection | back to summary |
|---|---|
| public JMSTopicRemoteConnection(RemoteCommandManager rcm, TopicConnectionFactory topicConnectionFactory, Topic topic, boolean isLocalConnectionBeingCreated, boolean reuseJMSTopicPublisher) throws JMSException INTERNAL: Constructor creating either a local or external connection. Local connections created this way connect to the topicSession and cache the session and subscriber. External connections cache only the topicConnection and will obtain the session/publisher when needed. | |
| JMSTopicRemoteConnection | back to summary |
|---|---|
| public JMSTopicRemoteConnection(RemoteCommandManager rcm) Creates local connections that do not use a TopicConnection or TopicSession, useful only for processing already received JMS messages
| |
| areAllResourcesFreedOnClose | back to summary |
|---|---|
| protected boolean areAllResourcesFreedOnClose() INTERNAL: Indicates whether all the resources used by connection are freed after close method returns. Usually that's the case. However in case of local (listening) JMSTopicRemoteConnection close merely indicates to the listening thread that it should free TopicConnection and exit. Note that it may take a while: the listening thread waits until subscriber.receive method either returns a message or throws an exception.
| |
| closeInternal | back to summary |
|---|---|
| protected void closeInternal() throws JMSException Implements abstract org. INTERNAL: This method is called by close method. This method usually (but not always see comment to areAllResourcesFreedOnClose method) frees all the resources.
| |
| createDisplayString | back to summary |
|---|---|
| protected void createDisplayString() INTERNAL: Used for debug logging
| |
| executeCommandInternal | back to summary |
|---|---|
| protected Object executeCommandInternal(Object command) throws Exception Implements abstract org. INTERNAL: Execute the remote command. The result of execution is returned. This method is used only by external (publishing) connection.
| |
| getPublisher | back to summary |
|---|---|
| public TopicPublisher getPublisher() | |
| getSubscriber | back to summary |
|---|---|
| public TopicSubscriber getSubscriber() | |
| getTopic | back to summary |
|---|---|
| public Topic getTopic() | |
| getTopicConnection | back to summary |
|---|---|
| public TopicConnection getTopicConnection() | |
| getTopicConnectionFactory | back to summary |
|---|---|
| public TopicConnection getTopicConnectionFactory() | |
| getTopicSession | back to summary |
|---|---|
| public TopicSession getTopicSession() | |
| isLocal | back to summary |
|---|---|
| public boolean isLocal() INTERNAL: Indicates whether connection is local (subscriber) or external (publisher). | |
| logDebugJMSTopic | back to summary |
|---|---|
| protected String logDebugJMSTopic(Message message) throws JMSException INTERNAL: | |
| onMessage | back to summary |
|---|---|
| public void onMessage(Message message) INTERNAL: Process received JMS message. This method is used only by local (listening) connection. | |
| run | back to summary |
|---|---|
| public void run() Implements java. INTERNAL: This method is used by local (listening) connection only. The only way to exit the loop is to set isActive to false - there should be no uncaught exceptions thrown from inside the loop. The execution exits the loop either in case of exception in remove connection on error mode; or by trasportManager.removeLocalConnection() call (which calls connection.close(), which sets isActive to false).
| |
| setPublisher | back to summary |
|---|---|
| public void setPublisher(TopicPublisher publisher) INTERNAL: set the TopicPublisher to be used when this RemoteConnection executes a command. Setting the TopicPublisher avoids having it obtained on each executeCommandInternal call. Passing in a publisher requires a TopicSession to also be set. These will not be closed until the external RemoteConnection is closed, and then only if the TopicConnection is also set. | |
| setSuscriber | back to summary |
|---|---|
| public void setSuscriber(TopicSubscriber subscriber) INTERNAL: set the TopicSubscriber on a local RemoteConnection for reading JMS messages when this runnable connection is started in a thread. If setting this, a TopicConnection is also required to be set, in order for it to be closed when the thread completes. This is only to be used when using the JMSTopicRemoteConnection(rcm) constructor. | |
| setTopic | back to summary |
|---|---|
| public void setTopic(Topic topic) INTERNAL: Set the Topic. The Topic is required with the TopicConnectionFactory to obtain connections if the TopicPublisher is not set. | |
| setTopicConnection | back to summary |
|---|---|
| public void setTopicConnection(TopicConnection topicConnection) INTERNAL: Set the TopicConnection. If this is set, a Publisher and TopicSession must also be set, or a new TopicConnection will be obtained on each executeCommandInternal call. This TopicConnection is only used on close, as closing the TopicConnection also closes any open TopicSessions and Publishers obtained from it. | |
| setTopicConnectionFactory | back to summary |
|---|---|
| public void setTopicConnectionFactory(TopicConnectionFactory topicConnectionFactory) INTERNAL: Set the TopicConnectionFactory, which is used if the publisher is not set to obtain the TopicConnection, TopicSession and TopicPublisher | |
| setTopicSession | back to summary |
|---|---|
| public void setTopicSession(TopicSession topicSession) INTERNAL: set the TopicSession to be used when this RemoteConnection executes a command if the publisher is also set. Setting the TopicSession and Publisher avoids having them obtained on each executeCommandInternal call. Passing in a TopicSession requires a TopicPublisher to also be set. These will not be closed until the external RemoteConnection is closed, and then only if the TopicConnection is also set. | |
| shouldCheckServiceId | back to summary |
|---|---|
| protected boolean shouldCheckServiceId() INTERNAL: Return whether a BroadcastConnection should check a ServiceId against its own ServiceId to avoid the processing of Commands with the same ServiceId. This should take place (return true) for a JMSTopicRemoteConnection.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| message | back to summary |
|---|---|
| pack-priv Message message | |
| JMSOnMessageHelper | back to summary |
|---|---|
| public JMSOnMessageHelper(Message message) | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |