Class Session
- java.lang.Object
-
- org.objectweb.joram.client.jms.Session
-
- All Implemented Interfaces:
AutoCloseable,Runnable,Session,SessionMBean
- Direct Known Subclasses:
QueueSession,TopicSession
public class Session extends Object implements Session, SessionMBean
Implements thejavax.jms.Sessioninterface.A Session object is a single-threaded context for producing and consuming messages. A session serves several purposes:
- It is a factory for message producers and consumers.
- It is a factory for Joram specific message.
- It defines a serial order for the messages it consumes and the messages it produces.
- It retains messages it consumes until they have been acknowledged.
- It serializes execution of message listeners registered with its message consumers.
- It is a factory for TemporaryTopics and TemporaryQueues.
- It supports a single series of transactions that combine work spanning its producers and consumers into atomic units.
- AUTO_ACKNOWLEDGE – With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message either when the session has successfully returned from a call to receive or when the message listener the session has called to process the message successfully returns.
- CLIENT_ACKNOWLEDGE – With this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method.
- DUPS_OK_ACKNOWLEDGE – This acknowledgment mode instructs the session to lazily acknowledge the delivery of messages.
- SESSION_TRANSACTED – This value is returned from the method getAcknowledgeMode if the session is transacted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classSession.CloserThis class synchronizes the close.private static classSession.MessageListenerContextContext used to associate a message consumer with a set of messages to consume.private static classSession.RequestStatusThe status of the current request.private classSession.SessionCloseTaskTheSessionCloseTaskclass is used by non-XA transacted sessions for taking care of closing them if they tend to be pending, and if a transaction timer has been set.private classSession.SessionDaemonThis thread controls the session in mode LISTENER.private static classSession.SessionModeThe way the session is used.private static classSession.StatusStatus of the session
-
Field Summary
Fields Modifier and Type Field Description private intacknowledgeModeThe acknowledgement mode of the session.private booleanasyncSendIndicates whether the messages produced are asynchronously sent or not (without or with acknowledgment).private booleanasyncSubIndicates whether the subscription requests are asynchronously handled or not.private booleanautoAcktrueif the session's acknowledgements are automatic.private Vector<QueueBrowser>browsersVector of queue browsers.private Session.ClosercloserUsed to synchronize the method close()private Session.SessionCloseTaskclosingTaskTask for closing the session if it becomes pending.private ConnectioncnxThe connection the session belongs to.private intcompressedMinSizeIf a message body is upper than thecompressedMinSize, this message body is compressed.private intcompressionLevelthe compression level (0-9)private Vector<MessageConsumer>consumersVector of message consumers.private Session.SessionDaemondaemonDaemon distributing asynchronous server deliveries.(package private) Hashtable<String,MessageAcks>deliveriesTable holding the identifiers of the messages delivered per destination or subscription, and not acknowledged.private StringidentThe identifier of the session.private booleanimplicitAckIndicates whether the messages consumed are implicitly acknowledged or not.static intINDIVIDUAL_ACKNOWLEDGEWith this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method.private List<MessageInterceptor>inInterceptors(package private) CompletionListenerlistenerThe CompletionListener.private intlistenerCountCounter of message listeners.static org.objectweb.util.monolog.api.Loggerloggerprivate MessageConsumerListenermessageConsumerListener(package private) Map<String,MessageConsumerListener>messageConsumerListenersMap of Message listener context (null if no message listener).protected MessageListenermessageListenerThe message listener of the session, if any.private RequestMultiplexermtpxThe request multiplexer used to communicate with the user proxy.private List<MessageInterceptor>outInterceptorsprivate MessageConsumerpendingMessageConsumerThe message consumer currently making a request (null if none).private Vector<MessageProducer>producersVector of message producers.private intqueueMessageReadMaxMaximum number of messages that can be read at once from a queue.private RequestorreceiveRequestorThe requestor used by the session to make 'receive' with the user proxy.private booleanrecoverIndicates that the session has been recovered by a message listener.private fr.dyade.aaa.common.QueuerepliesInFIFO queue holding the asynchronous server deliveries.private RequestorrequestorThe requestor used by the session to communicate with the user proxy.private intrequestStatusStatus of the request: NONE, RUN, DONE.private booleanscheduledtrueif the session's transaction is scheduled.(package private) Hashtable<String,org.objectweb.joram.shared.client.ProducerMessages>sendingsTable holding theProducerMessagesholding producers' messages and destinated to be sent at commit.private intsessionModeMode of the session: NONE, RECEIVE, LISTENER, APP_SERVERprivate ThreadsingleThreadOfControlThe current active control thread.private intstatusStatus of the session: STOP, START, CLOSEprivate StringstringImageprivate booleantoCloseIndicates that the session has been close by a message listener.private inttopicAckBufferMaxMaximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode.private inttopicActivationThresholdThis threshold is the minimum messages number below which the subscription is activated.private inttopicPassivationThresholdThis threshold is the maximum messages number over which the subscription is passivated.static org.objectweb.util.monolog.api.Loggertracestatic org.objectweb.util.monolog.api.Loggertracker(package private) booleantransactedtrueif the session is transacted.-
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
-
-
Constructor Summary
Constructors Constructor Description Session(Connection cnx, boolean transacted, int acknowledgeMode, RequestMultiplexer mtpx)Opens a session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidacknowledge()Method acknowledging the received messages.(package private) voidacknowledge(Destination dest, String msgId)Method acknowledging one received message.protected voidaddConsumer(MessageConsumer mc)Called here and by sub-classes.(package private) MessageConsumerListeneraddMessageListener(MessageConsumerListener mcl, boolean check)Called by MessageConsumerprotected voidaddProducer(MessageProducer mp)Called here and by sub-classes.private voidcheckClientID()private voidcheckCLMessageProducer(MessageProducer mp)protected voidcheckClosed()Checks if the session is closed.(package private) voidcheckConsumers(String agentId)Called by Connection (i.e. temporary destinations deletion)private voidcheckSessionMode(int expectedSessionMode)Checks the session mode.private voidcheckShared(Topic topic, String sharedSubscriptionName, String selector)(package private) booleancheckThread()private voidcheckThreadOfControl()Checks if the calling thread is the thread of control.voidclose()API method.(package private) voidcloseBrowser(QueueBrowser qb)Called by Queue browser.(package private) voidcloseConsumer(MessageConsumer mc)Called by MessageConsumer.(package private) voidcloseProducer(MessageProducer mp)Called by MessageProducer.voidcommit()API method.QueueBrowsercreateBrowser(Queue queue)API method.QueueBrowsercreateBrowser(Queue queue, String selector)API method.BytesMessagecreateBytesMessage()API method.MessageConsumercreateConsumer(Destination dest)API method.MessageConsumercreateConsumer(Destination dest, String selector)API method.MessageConsumercreateConsumer(Destination dest, String selector, boolean noLocal)API method.private StringcreateDestination(byte type, String name)Create a destination with the given name and type.MessageConsumercreateDurableConsumer(Topic topic, String name)API 2.0 method.MessageConsumercreateDurableConsumer(Topic topic, String name, String selector, boolean noLocal)API 2.0 method.TopicSubscribercreateDurableSubscriber(Topic topic, String name)API method.TopicSubscribercreateDurableSubscriber(Topic topic, String name, String selector, boolean noLocal)API method.MapMessagecreateMapMessage()API method.MessagecreateMessage()API method.ObjectMessagecreateObjectMessage()API method.ObjectMessagecreateObjectMessage(Serializable object)API method.MessageProducercreateProducer(Destination dest)API method.QueuecreateQueue(String name)This method allows to create or retrieve a Queue with the given name on the local server.MessageConsumercreateSharedConsumer(Topic topic, String sharedSubscriptionName)API 2.0 method.MessageConsumercreateSharedConsumer(Topic topic, String sharedSubscriptionName, String selector)API 2.0 method.MessageConsumercreateSharedDurableConsumer(Topic topic, String name)API 2.0 method.MessageConsumercreateSharedDurableConsumer(Topic topic, String name, String selector)API 2.0 method.StreamMessagecreateStreamMessage()API method.TemporaryQueuecreateTemporaryQueue()API method.TemporaryTopiccreateTemporaryTopic()API method.TextMessagecreateTextMessage()API method.TextMessagecreateTextMessage(String text)API method.TopiccreateTopic(String name)This method allows to create or retrieve a Topic with the given name on the local server.private voiddeny()Method denying the received messages.private voiddenyMessage(String targetName, String msgId, boolean queueMode, boolean redelivered)Called by: - method run (application server thread) synchronized - method onMessage (SessionDaemon thread) not synchronized but no concurrent call except a close which first stops SessionDaemon.private voiddoAcknowledge()Method acknowledging the received messages.(package private) voiddoClose()voiddoCommit()private voiddoRecover()voiddoRollback()private voiddoStart()private voiddoStop()intgetAcknowledgeMode()API method.intgetCompressedMinSize()Get the compressedMinSize for this session.intgetCompressionLevel()Get the compression level for this session.(package private) ConnectiongetConnection()(package private) StringgetId()StringgetJMXBeanName()Returns the MBean name.private MessageConsumergetMessageConsumer(String sharedSubscriptionName)(package private) MessageConsumerListenergetMessageConsumerListener(String targetName)MessageListenergetMessageListener()API method.intgetQueueMessageReadMax()Get the maximum number of messages that can be read at once from a queue for this Session.(package private) RequestMultiplexergetRequestMultiplexer()StringgetRequestStatus()The status of the current request.StringgetSessionMode()The way the session is used.StringgetStatus()Status of the sessionintgetTopicAckBufferMax()Get the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this session.intgetTopicActivationThreshold()Get the threshold of activation for this session.intgetTopicPassivationThreshold()Get the threshold of passivation for this session.booleangetTransacted()API method.booleanisAsyncSend()Indicates whether the messages produced are asynchronously sent or not (without or with acknowledgment).booleanisAsyncSub()Indicates whether the subscription request is asynchronously handled or not.booleanisAutoAck()trueif the session's acknowledgements are automatic.booleanisImplicitAck()Indicates whether the messages consumed are implicitly acknowledged or not.booleanisStarted()(package private) voidonMessage(org.objectweb.joram.shared.messages.Message msg)Called by ConnectionConsumer in order to distribute a message through the method run().(package private) voidonMessage(org.objectweb.joram.shared.messages.Message momMsg, MessageConsumerListener mcl)Called by onMessages()private voidonMessages(Session.MessageListenerContext ctx)Called by SessionDaemon.private voidpostReceive()Final stage after calling the reply has been returned by the proxy.private voidprepareAck(String name, String id, boolean queueMode)Method called by message consumers when receiving a message for preparing the session to later acknowledge or deny it.private voidprepareSend(Destination dest, org.objectweb.joram.shared.messages.Message msg)Method called by message producers when producing a message for preparing the session to later commit it.private voidpreReceive(MessageConsumer mc)First stage before calling the proxy and waiting for the reply.(package private) voidpushMessages(SingleSessionConsumer consumerListener, org.objectweb.joram.shared.client.ConsumerMessages messages)Called by MessageConsumerListener (demultiplexer thread from RequestMultiplexer) in order to distribute messages to a message consumer.(package private) voidputMessageConsumerListener(String targetName, MessageConsumerListener mcl)(package private) Messagereceive(long requestTimeToLive, long waitTimeOut, MessageConsumer mc, String targetName, String selector, boolean queueMode)Called by MessageConsumer.voidrecover()API method.StringregisterMBean()(package private) MessageConsumerListenerremoveMessageConsumerListener(String targetName)(package private) voidremoveMessageListener(MessageConsumerListener mcl, boolean check)Called by MessageConsumer.voidrollback()API method.voidrun()API method.(package private) voidsend(Destination dest, Message msg, int deliveryMode, int priority, long timeToLive, boolean timestampDisabled, long deliveryDelay, CompletionListener completionListener, MessageProducer messageProducer)Called by MessageProducer.voidsetAsyncSend(boolean asyncSend)Sets asynchronously sending for this session.voidsetAsyncSub(boolean asyncSub)Sets asynchronous subscription for this session.voidsetCompressedMinSize(int compressedMinSize)Sets the minimum size beyond which the message body is compressed in this session.voidsetCompressionLevel(int compressionLevel)Set the compression level for this session.voidsetImplicitAck(boolean implicitAck)Sets implicit acknowledge for this session.(package private) voidsetMessageConsumerListener(MessageConsumerListener mcl)Called by MultiSessionConsumer ASF modevoidsetMessageListener(MessageListener listener)API method.voidsetQueueMessageReadMax(int queueMessageReadMax)Set the maximum number of messages that can be read at once from a queue for this Session.private voidsetRequestStatus(int requestStatus)Sets the request status.private voidsetSessionMode(int sessionMode)Sets the session mode.private voidsetStatus(int status)Sets the status of the session.voidsetTopicAckBufferMax(int topicAckBufferMax)Set the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this session.voidsetTopicActivationThreshold(int topicActivationThreshold)Set the threshold of activation for this session.voidsetTopicPassivationThreshold(int topicPassivationThreshold)Set the threshold of passivation for this session.voidsetTransacted(boolean t)set transacted.(package private) voidstart()Starts the asynchronous deliveries in the session.(package private) voidstop()Stops the asynchronous deliveries processing in the session.(package private) org.objectweb.joram.shared.client.AbstractJmsReplysyncRequest(org.objectweb.joram.shared.client.AbstractJmsRequest request)Called by MessageConsumer.StringtoString()Returns a String image of this session.voidunregisterMBean()voidunsubscribe(String name)API method.
-
-
-
Field Detail
-
logger
public static org.objectweb.util.monolog.api.Logger logger
-
trace
public static org.objectweb.util.monolog.api.Logger trace
-
tracker
public static org.objectweb.util.monolog.api.Logger tracker
-
INDIVIDUAL_ACKNOWLEDGE
public static int INDIVIDUAL_ACKNOWLEDGE
With this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method. Contrary to CLIENT_ACKNOWLEDGE mode this mode allows to acknowledge only the specified message.
-
closingTask
private Session.SessionCloseTask closingTask
Task for closing the session if it becomes pending.
-
scheduled
private boolean scheduled
trueif the session's transaction is scheduled.
-
messageListener
protected MessageListener messageListener
The message listener of the session, if any.
-
ident
private final String ident
The identifier of the session.
-
cnx
private Connection cnx
The connection the session belongs to.
-
transacted
boolean transacted
trueif the session is transacted.
-
acknowledgeMode
private int acknowledgeMode
The acknowledgement mode of the session.
-
autoAck
private boolean autoAck
trueif the session's acknowledgements are automatic.
-
consumers
private Vector<MessageConsumer> consumers
Vector of message consumers.
-
producers
private Vector<MessageProducer> producers
Vector of message producers.
-
browsers
private Vector<QueueBrowser> browsers
Vector of queue browsers.
-
repliesIn
private fr.dyade.aaa.common.Queue repliesIn
FIFO queue holding the asynchronous server deliveries.
-
daemon
private Session.SessionDaemon daemon
Daemon distributing asynchronous server deliveries.
-
listenerCount
private int listenerCount
Counter of message listeners.
-
sendings
Hashtable<String,org.objectweb.joram.shared.client.ProducerMessages> sendings
Table holding theProducerMessagesholding producers' messages and destinated to be sent at commit.Key: destination name
Object:ProducerMessages
-
deliveries
Hashtable<String,MessageAcks> deliveries
Table holding the identifiers of the messages delivered per destination or subscription, and not acknowledged.Key: destination or subscription name
Object:MessageAcksinstance
-
listener
CompletionListener listener
The CompletionListener.
-
mtpx
private RequestMultiplexer mtpx
The request multiplexer used to communicate with the user proxy.
-
requestor
private Requestor requestor
The requestor used by the session to communicate with the user proxy.
-
receiveRequestor
private Requestor receiveRequestor
The requestor used by the session to make 'receive' with the user proxy. This second requestor is necessary because it must be closed during the session close (see method close).
-
recover
private boolean recover
Indicates that the session has been recovered by a message listener. Doesn't need to be volatile because it is only used by the SessionDaemon thread.
-
toClose
private boolean toClose
Indicates that the session has been close by a message listener. Doesn't need to be volatile because it is only used by the SessionDaemon thread.
-
status
private int status
Status of the session: STOP, START, CLOSE
-
sessionMode
private int sessionMode
Mode of the session: NONE, RECEIVE, LISTENER, APP_SERVER
-
requestStatus
private int requestStatus
Status of the request: NONE, RUN, DONE.
-
pendingMessageConsumer
private MessageConsumer pendingMessageConsumer
The message consumer currently making a request (null if none).
-
singleThreadOfControl
private Thread singleThreadOfControl
The current active control thread.
-
closer
private Session.Closer closer
Used to synchronize the method close()
-
implicitAck
private boolean implicitAck
Indicates whether the messages consumed are implicitly acknowledged or not. When true messages are immediately removed from queue when delivered. Contrary to Session's AUTO_ACKNOWLEDGE mode there is none acknowledge message from client to server.- See Also:
FactoryParameters.implicitAck
-
asyncSend
private boolean asyncSend
Indicates whether the messages produced are asynchronously sent or not (without or with acknowledgment).- See Also:
FactoryParameters.asyncSend
-
queueMessageReadMax
private int queueMessageReadMax
Maximum number of messages that can be read at once from a queue.This attribute is inherited from Connection at initialization.
- See Also:
FactoryParameters.queueMessageReadMax
-
topicAckBufferMax
private int topicAckBufferMax
Maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode.This attribute is inherited from Connection at initialization.
- See Also:
FactoryParameters.topicAckBufferMax
-
topicPassivationThreshold
private int topicPassivationThreshold
This threshold is the maximum messages number over which the subscription is passivated.This attribute is inherited from Connection at initialization, default value is Integer.MAX_VALUE.
- See Also:
FactoryParameters.topicPassivationThreshold
-
topicActivationThreshold
private int topicActivationThreshold
This threshold is the minimum messages number below which the subscription is activated.This attribute is inherited from Connection at initialization, default value is 0.
- See Also:
FactoryParameters.topicActivationThreshold
-
compressedMinSize
private int compressedMinSize
If a message body is upper than thecompressedMinSize, this message body is compressed.This attribute is inherited from Connection at initialization default value is 0 no compression
- See Also:
FactoryParameters.compressedMinSize
-
compressionLevel
private int compressionLevel
the compression level (0-9)This attribute is inherited from Connection at initialization default value is Deflater.BEST_SPEED (1)
- See Also:
FactoryParameters.compressionLevel
-
asyncSub
private boolean asyncSub
Indicates whether the subscription requests are asynchronously handled or not.Default value is false, the subscription is handled synchronously so the topic must be accessible.
- Since:
- JORAM 5.0.7
-
messageConsumerListener
private MessageConsumerListener messageConsumerListener
-
inInterceptors
private List<MessageInterceptor> inInterceptors
-
outInterceptors
private List<MessageInterceptor> outInterceptors
-
messageConsumerListeners
Map<String,MessageConsumerListener> messageConsumerListeners
Map of Message listener context (null if no message listener).
-
stringImage
private String stringImage
-
-
Constructor Detail
-
Session
Session(Connection cnx, boolean transacted, int acknowledgeMode, RequestMultiplexer mtpx) throws JMSException
Opens a session.- Parameters:
cnx- The connection the session belongs to.transacted-truefor a transacted session.acknowledgeMode- 1 (auto), 2 (client), 3 (dups ok), 4 (individual).- Throws:
JMSException- In case of an invalid acknowledge mode.
-
-
Method Detail
-
checkThread
boolean checkThread()
-
isImplicitAck
public boolean isImplicitAck()
Indicates whether the messages consumed are implicitly acknowledged or not. If true messages are immediately removed from queue when delivered.This attribute is inherited from Connection at initialization, by default false.
- Specified by:
isImplicitAckin interfaceSessionMBean- Returns:
- true if messages produced are implicitly acknowledged.
- See Also:
#implicitAck
-
setImplicitAck
public void setImplicitAck(boolean implicitAck)
Sets implicit acknowledge for this session.Determines whether the messages produced are implicitly acknowledged or not. If set to true the messages are immediately removed from queue when delivered.
This attribute is inherited from Connection at initialization, by default false.
- Parameters:
implicitAck- if true sets implicit acknowledge for this session.
-
isAsyncSend
public boolean isAsyncSend()
Indicates whether the messages produced are asynchronously sent or not (without or with acknowledgment).This attribute is inherited from Connection at initialization, by default false.
- Specified by:
isAsyncSendin interfaceSessionMBean- Returns:
- true if messages produced are asynchronously sent.
- See Also:
#asyncSend
-
setAsyncSend
public void setAsyncSend(boolean asyncSend)
Sets asynchronously sending for this session.Determines whether the messages produced are asynchronously sent or not (without or with acknowledgement).
This attribute is inherited from Connection at initialization, by default false.
- Parameters:
asyncSend- if true sets asynchronous sending for this session.- See Also:
FactoryParameters.asyncSend
-
getQueueMessageReadMax
public final int getQueueMessageReadMax()
Get the maximum number of messages that can be read at once from a queue for this Session.This attribute is inherited from Connection at initialization, default value is 1.
- Specified by:
getQueueMessageReadMaxin interfaceSessionMBean- Returns:
- The maximum number of messages that can be read at once from a queue.
- See Also:
FactoryParameters.queueMessageReadMax
-
setQueueMessageReadMax
public void setQueueMessageReadMax(int queueMessageReadMax)
Set the maximum number of messages that can be read at once from a queue for this Session.This attribute is inherited from Connection at initialization, default value is 1.
- Parameters:
queueMessageReadMax- The maximum number of messages that can be read at once from a queue.- See Also:
FactoryParameters.queueMessageReadMax
-
getTopicAckBufferMax
public final int getTopicAckBufferMax()
Get the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this session.This attribute is inherited from Connection at initialization.
- Specified by:
getTopicAckBufferMaxin interfaceSessionMBean- Returns:
- The Maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode.
- See Also:
FactoryParameters.topicAckBufferMax
-
setTopicAckBufferMax
public void setTopicAckBufferMax(int topicAckBufferMax)
Set the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this session.This attribute is inherited from Connection at initialization.
- Parameters:
topicAckBufferMax- The Maximum number of acknowledgements that can be buffered in Session.DUPS_OK_ACKNOWLEDGE mode.- See Also:
FactoryParameters.topicAckBufferMax
-
getTopicPassivationThreshold
public final int getTopicPassivationThreshold()
Get the threshold of passivation for this session.This threshold is the maximum messages number over which the subscription is passivated.
This attribute is inherited from Connection at initialization, default value is Integer.MAX_VALUE.
- Specified by:
getTopicPassivationThresholdin interfaceSessionMBean- Returns:
- The maximum messages number over which the subscription is passivated.
- See Also:
FactoryParameters.topicPassivationThreshold
-
setTopicPassivationThreshold
public void setTopicPassivationThreshold(int topicPassivationThreshold)
Set the threshold of passivation for this session.This threshold is the maximum messages number over which the subscription is passivated.
This attribute is inherited from Connection at initialization, default value is Integer.MAX_VALUE.
- Parameters:
topicPassivationThreshold- The maximum messages number over which the subscription is passivated.- See Also:
FactoryParameters.topicPassivationThreshold
-
getTopicActivationThreshold
public final int getTopicActivationThreshold()
Get the threshold of activation for this session.This threshold is the minimum messages number below which the subscription is activated.
This attribute is inherited from Connection at initialization, default value is 0.
- Specified by:
getTopicActivationThresholdin interfaceSessionMBean- Returns:
- The minimum messages number below which the subscription is activated.
- See Also:
FactoryParameters.topicActivationThreshold
-
setTopicActivationThreshold
public void setTopicActivationThreshold(int topicActivationThreshold)
Set the threshold of activation for this session.This threshold is the minimum messages number below which the subscription is activated.
This attribute is inherited from Connection at initialization, default value is 0.
- Parameters:
topicActivationThreshold- The minimum messages number below which the subscription is activated.- See Also:
FactoryParameters.topicActivationThreshold
-
getCompressedMinSize
public final int getCompressedMinSize()
Get the compressedMinSize for this session.The minimum message body size before a message body compression.
This attribute is inherited from Connection at initialization, default value is 0 no compression
- Specified by:
getCompressedMinSizein interfaceSessionMBean- Returns:
- The minimum size before a message body compression
- See Also:
FactoryParameters.compressedMinSize
-
setCompressedMinSize
public final void setCompressedMinSize(int compressedMinSize)
Sets the minimum size beyond which the message body is compressed in this session. This attribute is inherited from Connection at initialization, the default value is 0 (no compression).- Parameters:
compressedMinSize- The minimum size before a message body compression.- See Also:
FactoryParameters.compressedMinSize
-
getCompressionLevel
public final int getCompressionLevel()
Get the compression level for this session.This attribute is inherited from FactoryParameters, default value is Deflater.BEST_SPEED (1).
- Specified by:
getCompressionLevelin interfaceSessionMBean- Returns:
- The compression level
- See Also:
FactoryParameters.compressionLevel
-
setCompressionLevel
public final void setCompressionLevel(int compressionLevel)
Set the compression level for this session.This attribute is inherited from FactoryParameters, default value is Deflater.BEST_SPEED (1). This method can overload this attribute.
- Parameters:
The- compression level- See Also:
FactoryParameters.compressionLevel
-
isAsyncSub
public boolean isAsyncSub()
Indicates whether the subscription request is asynchronously handled or not.Default value is false, the subscription is handled synchronously so the topic must be accessible.
- Specified by:
isAsyncSubin interfaceSessionMBean- Returns:
- true if the subscription requests are asynchronously handled.
- Since:
- JORAM 5.0.7
-
setAsyncSub
public void setAsyncSub(boolean asyncSub)
Sets asynchronous subscription for this session.Determines whether the subscription request is asynchronously handled or not.
Default value is false, the subscription is handled synchronously so the topic must be accessible.
- Parameters:
asyncSub- if true sets asynchronous subscription for this session.- Since:
- JORAM 5.0.7
-
getMessageConsumerListener
MessageConsumerListener getMessageConsumerListener(String targetName)
-
putMessageConsumerListener
void putMessageConsumerListener(String targetName, MessageConsumerListener mcl)
-
removeMessageConsumerListener
MessageConsumerListener removeMessageConsumerListener(String targetName)
-
getJMXBeanName
public String getJMXBeanName()
Returns the MBean name.- Returns:
- the MBean name.
-
registerMBean
public String registerMBean()
-
unregisterMBean
public void unregisterMBean()
-
setStatus
private void setStatus(int status)
Sets the status of the session.
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceSessionMBean
-
getStatus
public String getStatus()
Description copied from interface:SessionMBeanStatus of the session- Specified by:
getStatusin interfaceSessionMBean
-
setSessionMode
private void setSessionMode(int sessionMode)
Sets the session mode.
-
getSessionMode
public String getSessionMode()
Description copied from interface:SessionMBeanThe way the session is used.- Specified by:
getSessionModein interfaceSessionMBean
-
setRequestStatus
private void setRequestStatus(int requestStatus)
Sets the request status.
-
getRequestStatus
public String getRequestStatus()
Description copied from interface:SessionMBeanThe status of the current request. Only valid in when the session is used to synchronously receive messages (RECEIVE mode).- Specified by:
getRequestStatusin interfaceSessionMBean
-
checkClosed
protected void checkClosed() throws IllegalStateExceptionChecks if the session is closed. If true, an IllegalStateException is raised.- Throws:
IllegalStateException
-
checkThreadOfControl
private void checkThreadOfControl() throws IllegalStateExceptionChecks if the calling thread is the thread of control. If not, an IllegalStateException is raised.- Throws:
IllegalStateException
-
checkSessionMode
private void checkSessionMode(int expectedSessionMode) throws IllegalStateExceptionChecks the session mode. If it is not the expected session mode, raises an IllegalStateException.- Parameters:
expectedSessionMode- the expected session mode.- Throws:
IllegalStateException
-
checkClientID
private void checkClientID() throws JMSException- Throws:
JMSException
-
toString
public final String toString()
Returns a String image of this session.
-
getAcknowledgeMode
public final int getAcknowledgeMode() throws JMSExceptionAPI method. Returns the acknowledgement mode of the session. The acknowledgement mode is set at the time that the session is created. If the session is transacted, the acknowledgement mode is ignored.- Specified by:
getAcknowledgeModein interfaceSession- Specified by:
getAcknowledgeModein interfaceSessionMBean- Returns:
- If the session is not transacted, returns the current acknowledgement mode for the session. If the session is transacted, returns Session.SESSION_TRANSACTED.
- Throws:
JMSException- Actually never thrown.
-
getTransacted
public final boolean getTransacted() throws JMSExceptionAPI method. Indicates whether the session is in transacted mode.- Specified by:
getTransactedin interfaceSession- Specified by:
getTransactedin interfaceSessionMBean- Returns:
- true if the session is in transacted mode.
- Throws:
IllegalStateException- If the session is closed.IllegalStateException- If the session is closed.JMSException
-
setTransacted
public void setTransacted(boolean t)
set transacted. see connector ManagedConnectionImpl (Connector).
-
setMessageListener
public void setMessageListener(MessageListener listener) throws JMSException
API method. Sets the session's distinguished message listener, this is an expert facility not used by regular JMS clients.When the distinguished message listener is set, no other form of message receipt in the session can be used; however, all forms of sending messages are still supported.
- Specified by:
setMessageListenerin interfaceSession- Parameters:
listener- the message listener to associate with this session.- Throws:
JMSException- Actually never thrown.
-
getMessageListener
public MessageListener getMessageListener() throws JMSException
API method. Returns the session's distinguished message listener, this is an expert facility not used by regular JMS clients.- Specified by:
getMessageListenerin interfaceSession- Returns:
- the message listener associated with this session
- Throws:
JMSException- Actually never thrown.
-
createMessage
public Message createMessage() throws JMSException
API method. Creates a Message object.- Specified by:
createMessagein interfaceSession- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
Message
-
createTextMessage
public TextMessage createTextMessage() throws JMSException
API method. Creates a TextMessage object, a TextMessage object is used to send a message containing a String object.- Specified by:
createTextMessagein interfaceSession- Returns:
- a newly created TextMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
TextMessage
-
createTextMessage
public TextMessage createTextMessage(String text) throws JMSException
API method. Creates a TextMessage object, a TextMessage object is used to send a message containing a String object.- Specified by:
createTextMessagein interfaceSession- Parameters:
text- the string to use to initialize this message.- Returns:
- a newly created TextMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
TextMessage
-
createBytesMessage
public BytesMessage createBytesMessage() throws JMSException
API method. Creates aBytesMessageobject, a BytesMessage object could be used to send a message containing a stream of uninterpreted bytes.- Specified by:
createBytesMessagein interfaceSession- Returns:
- a newly created ByteMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
BytesMessage
-
createMapMessage
public MapMessage createMapMessage() throws JMSException
API method. Creates aMapMessageobject, a MapMessage object is used to send a set of name-value pairs, where names are String objects and values are primitive values.- Specified by:
createMapMessagein interfaceSession- Returns:
- a newly created MapMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
MapMessage
-
createObjectMessage
public ObjectMessage createObjectMessage() throws JMSException
API method. Creates an ObjectMessage object, an ObjectMessage object is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessagein interfaceSession- Returns:
- a newly created ObjectMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
ObjectMessage
-
createObjectMessage
public ObjectMessage createObjectMessage(Serializable object) throws JMSException
API method. Creates an ObjectMessage object, an ObjectMessage object is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessagein interfaceSession- Parameters:
object- the object to use to initialize this message.- Returns:
- a newly created ObjectMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
ObjectMessage
-
createStreamMessage
public StreamMessage createStreamMessage() throws JMSException
API method. Creates a StreamMessage object, a StreamMessage object is used to send a self-defining stream of primitive values.- Specified by:
createStreamMessagein interfaceSession- Returns:
- a newly created StreamMessage object.
- Throws:
IllegalStateException- If the session is closed.JMSException- See Also:
StreamMessage
-
createBrowser
public QueueBrowser createBrowser(Queue queue, String selector) throws JMSException
API method. Creates a QueueBrowser object to peek at the messages on the specified queue using a message selector.- Specified by:
createBrowserin interfaceSession- Parameters:
queue- the queue to browseselector- the expression allowing to filter messages- Returns:
- a newly created QueueBrowser object.
- Throws:
IllegalStateException- if the session is closed.InvalidDestinationException- if an invalid destination is specified.InvalidSelectorException- if the message selector is invalid.JMSException
-
createBrowser
public QueueBrowser createBrowser(Queue queue) throws JMSException
API method. Creates a QueueBrowser object to peek at the messages on the specified queue.- Specified by:
createBrowserin interfaceSession- Parameters:
queue- the queue to browse- Returns:
- a newly created QueueBrowser object.
- Throws:
IllegalStateException- if the session is closed.InvalidDestinationException- if an invalid destination is specified.JMSException
-
createProducer
public MessageProducer createProducer(Destination dest) throws JMSException
API method. Creates a MessageProducer to send messages to the specified destination. A client uses a MessageProducer object to send messages to a destination.- Specified by:
createProducerin interfaceSession- Parameters:
dest- the Destination to send to, or null if this is a producer which does not have a specified destination.- Returns:
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the creation fails for any other reason.
-
createConsumer
public MessageConsumer createConsumer(Destination dest, String selector, boolean noLocal) throws JMSException
API method. Creates a MessageConsumer for the specified destination using a message selector. A client uses a MessageConsumer object to receive messages that have been sent to a destination.In some cases, a connection may both publish and subscribe to a topic. The consumer NoLocal attribute allows a consumer to inhibit the delivery of messages published by its own connection. The default value for this attribute is False. The noLocal value is only supported by destinations that are topics.
- Specified by:
createConsumerin interfaceSession- Parameters:
dest- the Destination to access.selector- The selector allowing to filter messages.noLocal- if true, and the destination is a topic, inhibits the delivery of messages published by its own connection.- Returns:
- the created MessageConsumer object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the creation fails for any other reason.
-
createConsumer
public MessageConsumer createConsumer(Destination dest, String selector) throws JMSException
API method. Creates a MessageConsumer for the specified destination using a message selector. A client uses a MessageConsumer object to receive messages that have been sent to a destination.- Specified by:
createConsumerin interfaceSession- Parameters:
dest- the Destination to access.selector- The selector allowing to filter messages.- Returns:
- the created MessageConsumer object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the creation fails for any other reason.
-
createConsumer
public MessageConsumer createConsumer(Destination dest) throws JMSException
API method. Creates a MessageConsumer for the specified destination. A client uses a MessageConsumer object to receive messages that have been sent to a destination.- Specified by:
createConsumerin interfaceSession- Parameters:
dest- the Destination to access.- Returns:
- the created MessageConsumer object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the creation fails for any other reason.
-
createDurableSubscriber
public TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal) throws JMSException
API method. Creates a durable subscriber to the specified topic, using a message selector and specifying whether messages published by its own connection should be delivered to it.If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it needs to use a durable TopicSubscriber. Joram retains a record of durable subscriptions and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.
A client can change an existing durable subscription by creating a durable TopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.
- Specified by:
createDurableSubscriberin interfaceSession- Parameters:
topic- the non-temporary Topic to subscribe to.name- the name used to identify this subscription.selector- The selector allowing to filter messages. A value of null or an empty string indicates that there is no message selector for the message consumer.noLocal- if true, inhibits the delivery of messages published by its own connection.- Returns:
- the created TopicSubscriber object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken or if the client identifier is unset.JMSException- If the creation fails for any other reason.
-
createDurableSubscriber
public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
API method. Creates a durable subscriber to the specified topic.If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it needs to use a durable TopicSubscriber. Joram retains a record of durable subscriptions and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.
A client can change an existing durable subscription by creating a durable TopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.
- Specified by:
createDurableSubscriberin interfaceSession- Parameters:
topic- the non-temporary Topic to subscribe to.name- the name used to identify this subscription.- Returns:
- the created TopicSubscriber object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken or if the client identifier is unset.JMSException- If the creation fails for any other reason.
-
createQueue
public Queue createQueue(String name) throws JMSException
This method allows to create or retrieve a Queue with the given name on the local server. First a destination with the specified name is searched on the server, if it does not exist it is created. In any case a queue identity with its Joram specific address is returned.If the given name is a provider-specific name ("#x.y.z" unique identifier) a queue identity is returned with the specified identifier.
API method.
Clients that depend on this ability are not portable. Normally the physical creation of destination is an administrative task and is not to be initiated by the JMS API.
- Specified by:
createQueuein interfaceSession- Parameters:
name- the name of this queue.- Returns:
- a queue with the given name.
- Throws:
IllegalStateException- If the session is closed.JMSException- If the topic creation failed.- See Also:
Queue
-
createTopic
public Topic createTopic(String name) throws JMSException
This method allows to create or retrieve a Topic with the given name on the local server. First a destination with the specified name is searched on the server, if it does not exist it is created. In any case a topic identity with its provider-specific address is returned.If the given name is a Joram specific name ("#x.y.z" unique identifier) a topic identity is returned with the specified identifier.
API method.
Clients that depend on this ability are not portable. Normally the physical creation of destination is an administrative task and is not to be initiated by the JMS API.
- Specified by:
createTopicin interfaceSession- Parameters:
name- the name of this topic.- Returns:
- a topic with the given name.
- Throws:
IllegalStateException- If the session is closed.JMSException- If the topic creation failed.- See Also:
Topic
-
createDestination
private String createDestination(byte type, String name) throws JMSException
Create a destination with the given name and type. If a destination of a corresponding name and type exists it is returned.- Parameters:
type- the type of the destination to create.name- the name of the destination to create.- Returns:
- the unique identifier of the created destination.
- Throws:
JMSException
-
createTemporaryQueue
public TemporaryQueue createTemporaryQueue() throws JMSException
API method. Creates a TemporaryQueue object. Its lifetime will be that of the Connection unless it is deleted earlier.- Specified by:
createTemporaryQueuein interfaceSession- Returns:
- a temporary queue identity.
- Throws:
IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the request fails for any other reason.- See Also:
TemporaryQueue
-
createTemporaryTopic
public TemporaryTopic createTemporaryTopic() throws JMSException
API method. Creates a TemporaryTopic object. Its lifetime will be that of the Connection unless it is deleted earlier.- Specified by:
createTemporaryTopicin interfaceSession- Returns:
- a temporary topic identity.
- Throws:
IllegalStateException- If the session is closed or if the connection is broken.JMSException- If the request fails for any other reason.- See Also:
TemporaryTopic
-
run
public void run()
API method.
-
setMessageConsumerListener
void setMessageConsumerListener(MessageConsumerListener mcl)
Called by MultiSessionConsumer ASF mode
-
commit
public void commit() throws JMSExceptionAPI method. Commits all messages done in this transaction and releases any locks currently held.- Specified by:
commitin interfaceSession- Throws:
IllegalStateException- If the session is closed, or not transacted, or if the connection is broken.JMSException
-
doCommit
public void doCommit() throws JMSException- Throws:
JMSException
-
rollback
public void rollback() throws JMSExceptionAPI method. Rolls back any messages done in this transaction and releases any locks currently held.- Specified by:
rollbackin interfaceSession- Throws:
IllegalStateException- If the session is closed, or not transacted.JMSException
-
doRollback
public void doRollback() throws JMSException- Throws:
JMSException
-
recover
public void recover() throws JMSExceptionAPI method. Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.- Specified by:
recoverin interfaceSession- Throws:
IllegalStateException- If the session is closed, or transacted.JMSException
-
doRecover
private void doRecover() throws JMSException- Throws:
JMSException
-
unsubscribe
public void unsubscribe(String name) throws JMSException
API method. Unsubscribes a durable subscription that has been created by a client, this method deletes the state being maintained on behalf of the subscriber by the Joram server.It is erroneous for a client to delete a durable subscription while there is an active MessageConsumer for the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.
- Specified by:
unsubscribein interfaceSession- Specified by:
unsubscribein interfaceSessionMBean- Parameters:
name- the name used to identify this subscription.- Throws:
IllegalStateException- If the session is closed or if the connection is broken.InvalidDestinationException- If the subscription does not exist.JMSException- If the request fails for any other reason.
-
close
public void close() throws JMSExceptionAPI method. Closes the session.In order to free significant resources allocated on behalf of a session, clients should close sessions when they are not needed. Closing a session automatically close all related producers, and consumers and causes all temporary destinations to be deleted.
This call will block until a receive call or message listener in progress has completed. A blocked message consumer receive call returns null when this session is closed. Closing a transacted session must roll back the transaction in progress.
This method is the only Session method that can be called concurrently.
Invoking any other Session method on a closed session must throw a JMSException.IllegalStateException. Closing a closed session must not throw an exception.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSession- Specified by:
closein interfaceSessionMBean- Throws:
JMSException- if the JMS provider fails to close the session due to some internal error.
-
doClose
void doClose() throws JMSException- Throws:
JMSException
-
start
void start()
Starts the asynchronous deliveries in the session.This method is called by a started connection.
-
doStart
private void doStart()
-
stop
void stop()
Stops the asynchronous deliveries processing in the session.This method must be carefully used. When the session is stopped, the connection might very well going on pushing deliveries in the session's queue. If the session is never re-started, these deliveries will never be popped out, and this may lead to a situation of consumed but never acknowledged messages.
This fatal situation never occurs as the
stop()method is either called by heSession.close()andConnection.stop()methods, which first empties the session's deliveries and forbid any further push.
-
doStop
private void doStop()
-
prepareSend
private void prepareSend(Destination dest, org.objectweb.joram.shared.messages.Message msg) throws JMSException
Method called by message producers when producing a message for preparing the session to later commit it.- Parameters:
dest- The destination the message is destinated to.msg- The message.- Throws:
JMSException
-
prepareAck
private void prepareAck(String name, String id, boolean queueMode)
Method called by message consumers when receiving a message for preparing the session to later acknowledge or deny it.- Parameters:
name- Name of the destination or of the proxy subscription the message comes from.id- Identifier of the consumed message.queueMode-trueif the message consumed comes from a queue.
-
acknowledge
void acknowledge() throws JMSExceptionMethod acknowledging the received messages. Called by Message.- Throws:
JMSException
-
doAcknowledge
private void doAcknowledge() throws JMSExceptionMethod acknowledging the received messages.- Throws:
JMSException
-
acknowledge
void acknowledge(Destination dest, String msgId) throws JMSException
Method acknowledging one received message. Called by Message.- Throws:
JMSException
-
deny
private void deny() throws JMSExceptionMethod denying the received messages. Called from: - rollback -> synchronized client thread - recover -> synchronized client thread - close -> synchronized client thread - onMessage -> not synchronized session daemon. It is the only thread that can run into the session (session mode = LISTENER) except for the method close that can be called concurrently. But close() first stops the session daemon and then calls deny(). The hashtable deliveries is also accessed from: - acknowledge -> synchronized client thread - commit -> synchronized client thread - receive -> synchronized client thread. - onMessage -> not synchronized session daemon (see above).- Throws:
JMSException
-
receive
Message receive(long requestTimeToLive, long waitTimeOut, MessageConsumer mc, String targetName, String selector, boolean queueMode) throws JMSException
Called by MessageConsumer. This method is not synchronized because it can be concurrently called by close() and Connection.stop().- Throws:
JMSException
-
preReceive
private void preReceive(MessageConsumer mc) throws JMSException
First stage before calling the proxy and waiting for the reply. It is synchronized because it locks the session in order to prevent any other thread to make another operation.- Throws:
JMSException
-
postReceive
private void postReceive()
Final stage after calling the reply has been returned by the proxy. It releases the session and enables another thread to call it.
-
addConsumer
protected void addConsumer(MessageConsumer mc)
Called here and by sub-classes.
-
closeConsumer
void closeConsumer(MessageConsumer mc)
Called by MessageConsumer.
-
checkConsumers
void checkConsumers(String agentId) throws JMSException
Called by Connection (i.e. temporary destinations deletion)- Throws:
JMSException
-
checkCLMessageProducer
private void checkCLMessageProducer(MessageProducer mp) throws IllegalStateException
- Throws:
IllegalStateException
-
addProducer
protected void addProducer(MessageProducer mp)
Called here and by sub-classes.
-
closeProducer
void closeProducer(MessageProducer mp) throws IllegalStateException
Called by MessageProducer.- Throws:
IllegalStateException
-
closeBrowser
void closeBrowser(QueueBrowser qb)
Called by Queue browser.
-
addMessageListener
MessageConsumerListener addMessageListener(MessageConsumerListener mcl, boolean check) throws JMSException
Called by MessageConsumer- Throws:
JMSException
-
removeMessageListener
void removeMessageListener(MessageConsumerListener mcl, boolean check) throws JMSException
Called by MessageConsumer. The thread of control and the status must be checked if the call results from a setMessageListener but not from a close.- Throws:
JMSException
-
pushMessages
void pushMessages(SingleSessionConsumer consumerListener, org.objectweb.joram.shared.client.ConsumerMessages messages)
Called by MessageConsumerListener (demultiplexer thread from RequestMultiplexer) in order to distribute messages to a message consumer. Not synchronized because a concurrent close can be done.
-
onMessage
void onMessage(org.objectweb.joram.shared.messages.Message msg)
Called by ConnectionConsumer in order to distribute a message through the method run(). Session mode is APP_SERVER.
-
denyMessage
private void denyMessage(String targetName, String msgId, boolean queueMode, boolean redelivered) throws JMSException
Called by: - method run (application server thread) synchronized - method onMessage (SessionDaemon thread) not synchronized but no concurrent call except a close which first stops SessionDaemon.- Throws:
JMSException
-
onMessages
private void onMessages(Session.MessageListenerContext ctx) throws JMSException
Called by SessionDaemon. Not synchronized but no concurrent call except a close which first stops SessionDaemon.- Throws:
JMSException
-
onMessage
void onMessage(org.objectweb.joram.shared.messages.Message momMsg, MessageConsumerListener mcl) throws JMSExceptionCalled by onMessages()- Throws:
JMSException
-
send
void send(Destination dest, Message msg, int deliveryMode, int priority, long timeToLive, boolean timestampDisabled, long deliveryDelay, CompletionListener completionListener, MessageProducer messageProducer) throws JMSException
Called by MessageProducer.- Throws:
JMSException
-
syncRequest
org.objectweb.joram.shared.client.AbstractJmsReply syncRequest(org.objectweb.joram.shared.client.AbstractJmsRequest request) throws JMSExceptionCalled by MessageConsumer. The requestor raises an exception if it is called during another request. This cannot happen as a session is monothreaded. A concurrent close first aborts the current request so it releases the requestor for a subsequent use.- Throws:
JMSException
-
getConnection
final Connection getConnection()
-
getId
final String getId()
-
getRequestMultiplexer
final RequestMultiplexer getRequestMultiplexer()
-
isAutoAck
public final boolean isAutoAck()
Description copied from interface:SessionMBeantrueif the session's acknowledgements are automatic.- Specified by:
isAutoAckin interfaceSessionMBean
-
getMessageConsumer
private MessageConsumer getMessageConsumer(String sharedSubscriptionName)
-
checkShared
private void checkShared(Topic topic, String sharedSubscriptionName, String selector) throws JMSException
- Throws:
JMSException
-
createSharedConsumer
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException
API 2.0 method.- Specified by:
createSharedConsumerin interfaceSession- Throws:
JMSException
-
createSharedConsumer
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String selector) throws JMSException
API 2.0 method.- Specified by:
createSharedConsumerin interfaceSession- Throws:
JMSException
-
createDurableConsumer
public MessageConsumer createDurableConsumer(Topic topic, String name) throws JMSException
API 2.0 method. Creates a durable consumer to the specified topic.If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it needs to use a durable TopicSubscriber. Joram retains a record of durable subscribers and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable consumer or they have expired.
A client can change an existing durable consumer by creating a durable MessageConsumer with the same name and a new topic and/or message selector. Changing a durable consumer is equivalent to unsubscribing (deleting) the old one and creating a new one.
- Specified by:
createDurableConsumerin interfaceSession- Parameters:
topic- the non-temporary Topic to subscribe to.name- the name used to identify this subscription.- Returns:
- the created MessageConsumer object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken or if the client identifier is unset.JMSException- If the creation fails for any other reason.
-
createDurableConsumer
public MessageConsumer createDurableConsumer(Topic topic, String name, String selector, boolean noLocal) throws JMSException
API 2.0 method. Creates a durable consumer to the specified topic.If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it needs to use a durable TopicSubscriber. Joram retains a record of durable subscribers and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable consumer or they have expired.
A client can change an existing durable consumer by creating a durable MessageConsumer with the same name and a new topic and/or message selector. Changing a durable consumer is equivalent to unsubscribing (deleting) the old one and creating a new one.
- Specified by:
createDurableConsumerin interfaceSession- Parameters:
topic- the non-temporary Topic to subscribe to.name- the name used to identify this subscription.selector- the selector used to filter incoming messages.noLocal- if true, inhibits the delivery of messages published by its own connection.- Returns:
- the created MessageConsumer object.
- Throws:
InvalidDestinationException- if an invalid destination is specified.IllegalStateException- If the session is closed or if the connection is broken or if the client identifier is unset.JMSException- If the creation fails for any other reason.
-
createSharedDurableConsumer
public MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException
API 2.0 method.- Specified by:
createSharedDurableConsumerin interfaceSession- Throws:
JMSException
-
createSharedDurableConsumer
public MessageConsumer createSharedDurableConsumer(Topic topic, String name, String selector) throws JMSException
API 2.0 method.- Specified by:
createSharedDurableConsumerin interfaceSession- Throws:
JMSException
-
-