Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.sessions.coordination.jms

public Class JMSTopicRemoteConnection

extends BroadcastRemoteConnection
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.Serializable, jakarta.jms.BytesMessage, .JMSException, .Message, .ObjectMessage, .Topic, .TopicConnection, .TopicConnectionFactory, .TopicPublisher, .TopicSession, .TopicSubscriber, org.eclipse.persistence.exceptions.RemoteCommandManagerException, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection, org.eclipse.persistence.sessions.coordination.RemoteCommandManager, org.eclipse.persistence.sessions.coordination.jms.JMSTopicTransportManager, org.eclipse.persistence.sessions.serializers.JavaSerializer, .Serializer

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)

Author
Steven Vo
Since
OracleAS TopLink 10g (10.0.3)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
protected boolean
private TopicPublisher
protected TopicSubscriber
protected Topic
protected TopicConnection
protected TopicConnectionFactory
protected TopicSession
public static long
Inherited from org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection:
displayStringinfoinfoExtrcmstateSTATE_ACTIVESTATE_CLOSEDSTATE_CLOSINGtopicName

Constructor Summary

AccessConstructor 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

Method Summary

Modifier and TypeMethod and Description
protected boolean
areAllResourcesFreedOnClose()

Overrides org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.areAllResourcesFreedOnClose.

INTERNAL: Indicates whether all the resources used by connection are freed after close method returns.
protected void
protected void
protected Object
public TopicPublisher
public TopicSubscriber
public Topic
public TopicConnection
public TopicConnection
public TopicSession
public boolean
isLocal()

INTERNAL: Indicates whether connection is local (subscriber) or external (publisher).

protected String
logDebugJMSTopic(Message message)

INTERNAL:

public void
onMessage(Message message)

INTERNAL: Process received JMS message.

public void
run()

Implements java.lang.Runnable.run.

INTERNAL: This method is used by local (listening) connection only.
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
setTopic(Topic topic)

INTERNAL: Set the Topic.

public void
setTopicConnection(TopicConnection topicConnection)

INTERNAL: Set the TopicConnection.

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
shouldCheckServiceId
()

Overrides org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.shouldCheckServiceId.

INTERNAL: Return whether a BroadcastConnection should check a ServiceId against its own ServiceId to avoid the processing of Commands with the same ServiceId.
Inherited from org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection:
closeexecuteCommandexecuteCommandfailDeserializeMessagegetInfogetInfoExtgetStategetTopicNameisActiveisClosedisClosinglogDebugAfterPublishlogDebugBeforePublishlogDebugOnReceiveMessageprocessReceivedObjecttoString

Field Detail

isLocalback to summary
protected boolean isLocal
publisherback to summary
private TopicPublisher publisher
subscriberback to summary
protected TopicSubscriber subscriber
topicback to summary
protected Topic topic
topicConnectionback to summary
protected TopicConnection topicConnection
topicConnectionFactoryback to summary
protected TopicConnectionFactory topicConnectionFactory
topicSessionback to summary
protected TopicSession topicSession
WAIT_ON_ERROR_RECEIVING_JMS_MESSAGEback to summary
public static long WAIT_ON_ERROR_RECEIVING_JMS_MESSAGE

Constructor Detail

JMSTopicRemoteConnectionback 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.

JMSTopicRemoteConnectionback 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

See Also
onMessage

Method Detail

areAllResourcesFreedOnCloseback to summary
protected boolean areAllResourcesFreedOnClose()

Overrides org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.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.

Annotations
@Override
closeInternalback to summary
protected void closeInternal() throws JMSException

Implements abstract org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.closeInternal.

INTERNAL: This method is called by close method. This method usually (but not always see comment to areAllResourcesFreedOnClose method) frees all the resources.

Annotations
@Override
createDisplayStringback to summary
protected void createDisplayString()

Overrides org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.createDisplayString.

INTERNAL: Used for debug logging

Annotations
@Override
executeCommandInternalback to summary
protected Object executeCommandInternal(Object command) throws Exception

Implements abstract org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.executeCommandInternal.

INTERNAL: Execute the remote command. The result of execution is returned. This method is used only by external (publishing) connection.

Annotations
@Override
getPublisherback to summary
public TopicPublisher getPublisher()
getSubscriberback to summary
public TopicSubscriber getSubscriber()
getTopicback to summary
public Topic getTopic()
getTopicConnectionback to summary
public TopicConnection getTopicConnection()
getTopicConnectionFactoryback to summary
public TopicConnection getTopicConnectionFactory()
getTopicSessionback to summary
public TopicSession getTopicSession()
isLocalback to summary
public boolean isLocal()

INTERNAL: Indicates whether connection is local (subscriber) or external (publisher).

logDebugJMSTopicback to summary
protected String logDebugJMSTopic(Message message) throws JMSException

INTERNAL:

onMessageback to summary
public void onMessage(Message message)

INTERNAL: Process received JMS message. This method is used only by local (listening) connection.

runback to summary
public void run()

Implements java.lang.Runnable.run.

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).

Annotations
@Override
setPublisherback 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.

setSuscriberback 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.

setTopicback 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.

setTopicConnectionback 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.

setTopicConnectionFactoryback 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

setTopicSessionback 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.

shouldCheckServiceIdback to summary
protected boolean shouldCheckServiceId()

Overrides org.eclipse.persistence.internal.sessions.coordination.broadcast.BroadcastRemoteConnection.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.

Returns:boolean

boolean

Annotations
@Override
org.eclipse.persistence.internal.sessions.coordination.jms back to summary

pack-priv Class JMSTopicRemoteConnection.JMSOnMessageHelper

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.eclipse.persistence.internal.sessions.coordination.jms.JMSTopicRemoteConnection.JMSOnMessageHelper
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv Message

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

messageback to summary
pack-priv Message message

Constructor Detail

JMSOnMessageHelperback to summary
public JMSOnMessageHelper(Message message)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override