public class JMSTopicRemoteConnection extends BroadcastRemoteConnection implements java.lang.Runnable
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 | Field and Description |
---|---|
static long |
WAIT_ON_ERROR_RECEIVING_JMS_MESSAGE |
STATE_ACTIVE, STATE_CLOSED, STATE_CLOSING
Constructor and Description |
---|
JMSTopicRemoteConnection(RemoteCommandManager rcm)
Creates local connections that do not use a TopicConnection or TopicSession,
useful only for processing already received JMS messages
|
JMSTopicRemoteConnection(RemoteCommandManager rcm,
javax.jms.TopicConnectionFactory topicConnectionFactory,
javax.jms.Topic topic,
boolean isLocalConnectionBeingCreated,
boolean reuseJMSTopicPublisher)
INTERNAL:
Constructor creating either a local or external connection.
|
Modifier and Type | Method and Description |
---|---|
javax.jms.TopicPublisher |
getPublisher() |
javax.jms.TopicSubscriber |
getSubscriber() |
javax.jms.Topic |
getTopic() |
javax.jms.TopicConnection |
getTopicConnection() |
javax.jms.TopicConnection |
getTopicConnectionFactory() |
javax.jms.TopicSession |
getTopicSession() |
boolean |
isLocal()
INTERNAL:
Indicates whether connection is local (subscriber)
or external (publisher).
|
void |
onMessage(javax.jms.Message message)
INTERNAL:
Process received JMS message.
|
void |
run()
INTERNAL:
This method is used by local (listening) connection only.
|
void |
setPublisher(javax.jms.TopicPublisher publisher)
INTERNAL:
set the TopicPublisher to be used when this RemoteConnection executes a command.
|
void |
setSuscriber(javax.jms.TopicSubscriber subscriber)
INTERNAL:
set the TopicSubscriber on a local RemoteConnection for reading JMS messages when
this runnable connection is started in a thread.
|
void |
setTopic(javax.jms.Topic topic)
INTERNAL:
Set the Topic.
|
void |
setTopicConnection(javax.jms.TopicConnection topicConnection)
INTERNAL:
Set the TopicConnection.
|
void |
setTopicConnectionFactory(javax.jms.TopicConnectionFactory topicConnectionFactory)
INTERNAL:
Set the TopicConnectionFactory, which is used if the publisher is not set to
obtain the TopicConnection, TopicSession and TopicPublisher
|
void |
setTopicSession(javax.jms.TopicSession topicSession)
INTERNAL:
set the TopicSession to be used when this RemoteConnection executes a command if
the publisher is also set.
|
close, executeCommand, executeCommand, getState, getTopicName, isActive, isClosed, isClosing, toString
getServiceId, setServiceId
public static long WAIT_ON_ERROR_RECEIVING_JMS_MESSAGE
public JMSTopicRemoteConnection(RemoteCommandManager rcm, javax.jms.TopicConnectionFactory topicConnectionFactory, javax.jms.Topic topic, boolean isLocalConnectionBeingCreated, boolean reuseJMSTopicPublisher) throws javax.jms.JMSException
rcm
- javax.jms.JMSException
public JMSTopicRemoteConnection(RemoteCommandManager rcm)
rcm
- onMessage
public boolean isLocal()
public void onMessage(javax.jms.Message message)
public void run()
run
in interface java.lang.Runnable
public void setPublisher(javax.jms.TopicPublisher publisher)
public javax.jms.TopicPublisher getPublisher()
public void setSuscriber(javax.jms.TopicSubscriber subscriber)
public javax.jms.TopicSubscriber getSubscriber()
public void setTopicSession(javax.jms.TopicSession topicSession)
public javax.jms.TopicSession getTopicSession()
public void setTopicConnectionFactory(javax.jms.TopicConnectionFactory topicConnectionFactory)
public javax.jms.TopicConnection getTopicConnectionFactory()
public void setTopicConnection(javax.jms.TopicConnection topicConnection)
public javax.jms.TopicConnection getTopicConnection()
public void setTopic(javax.jms.Topic topic)
public javax.jms.Topic getTopic()
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference