public class Session extends Object implements Session, SessionMBean
javax.jms.Session
interface.
A Session object is a single-threaded context for producing and consuming messages. A session serves several purposes:
Modifier and Type | Class and Description |
---|---|
(package private) class |
Session.Closer
This class synchronizes the close.
|
private static class |
Session.MessageListenerContext
Context used to associate a message consumer with
a set of messages to consume.
|
private static class |
Session.RequestStatus
The status of the current request.
|
private class |
Session.SessionCloseTask
The
SessionCloseTask class 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 class |
Session.SessionDaemon
This thread controls the session in mode LISTENER.
|
private static class |
Session.SessionMode
The way the session is used.
|
private static class |
Session.Status
Status of the session
|
Modifier and Type | Field and Description |
---|---|
private int |
acknowledgeMode
The acknowledgement mode of the session.
|
private boolean |
asyncSend
Indicates whether the messages produced are asynchronously sent
or not (without or with acknowledgment).
|
private boolean |
asyncSub
Indicates whether the subscription requests are asynchronously handled
or not.
|
private boolean |
autoAck
true if the session's acknowledgements are automatic. |
private Vector |
browsers
Vector of queue browsers.
|
private Session.Closer |
closer
Used to synchronize the method close()
|
private Session.SessionCloseTask |
closingTask
Task for closing the session if it becomes pending.
|
private Connection |
cnx
The connection the session belongs to.
|
private int |
compressedMinSize
If a message body is upper than the
compressedMinSize ,
this message body is compressed. |
private int |
compressionLevel
the compression level (0-9)
This attribute is inherited from Connection at initialization
default value is Deflater.BEST_SPEED (1)
|
private Vector<MessageConsumer> |
consumers
Vector of message consumers.
|
private Session.SessionDaemon |
daemon
Daemon distributing asynchronous server deliveries.
|
(package private) Hashtable |
deliveries
Table holding the identifiers of the messages delivered per
destination or subscription, and not acknowledged.
|
private String |
ident
The identifier of the session.
|
private boolean |
implicitAck
Indicates whether the messages consumed are implicitly acknowledged
or not.
|
static int |
INDIVIDUAL_ACKNOWLEDGE
With this acknowledgment mode, the client acknowledges a consumed message by calling
the message's acknowledge method.
|
private List |
inInterceptors |
(package private) CompletionListener |
listener
The CompletionListener.
|
private int |
listenerCount
Counter of message listeners.
|
static org.objectweb.util.monolog.api.Logger |
logger |
private MessageConsumerListener |
messageConsumerListener |
(package private) Map<String,MessageConsumerListener> |
messageConsumerListeners
Map of Message listener context (null if no message listener).
|
protected MessageListener |
messageListener
The message listener of the session, if any.
|
private RequestMultiplexer |
mtpx
The request multiplexer used to communicate with the user proxy.
|
private List |
outInterceptors |
private MessageConsumer |
pendingMessageConsumer
The message consumer currently making a request (null if none).
|
private Vector |
producers
Vector of message producers.
|
private int |
queueMessageReadMax
Maximum number of messages that can be read at once from a queue.
|
private Requestor |
receiveRequestor
The requestor used by the session to make 'receive' with the user
proxy.
|
private boolean |
recover
Indicates that the session has been recovered by a message listener.
|
private Queue |
repliesIn
FIFO queue holding the asynchronous server deliveries.
|
private Requestor |
requestor
The requestor used by the session to communicate with the user proxy.
|
private int |
requestStatus
Status of the request: NONE, RUN, DONE.
|
private boolean |
scheduled
true if the session's transaction is scheduled. |
(package private) Hashtable |
sendings
Table holding the
ProducerMessages holding producers'
messages and destinated to be sent at commit. |
private int |
sessionMode
Mode of the session: NONE, RECEIVE, LISTENER, APP_SERVER
|
private Thread |
singleThreadOfControl
The current active control thread.
|
private int |
status
Status of the session: STOP, START, CLOSE
|
private boolean |
toClose
Indicates that the session has been close by a message listener.
|
private int |
topicAckBufferMax
Maximum number of acknowledgements that can be buffered when using
Session.DUPS_OK_ACKNOWLEDGE mode.
|
private int |
topicActivationThreshold
This threshold is the minimum messages number below which
the subscription is activated.
|
private int |
topicPassivationThreshold
This threshold is the maximum messages number over which the
subscription is passivated.
|
static org.objectweb.util.monolog.api.Logger |
trace |
(package private) boolean |
transacted
true if the session is transacted. |
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
Constructor and Description |
---|
Session(Connection cnx,
boolean transacted,
int acknowledgeMode,
RequestMultiplexer mtpx)
Opens a session.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
acknowledge()
Method acknowledging the received messages.
|
(package private) void |
acknowledge(Destination dest,
String msgId)
Method acknowledging one received message.
|
protected void |
addConsumer(MessageConsumer mc)
Called here and by sub-classes.
|
(package private) MessageConsumerListener |
addMessageListener(MessageConsumerListener mcl,
boolean check)
Called by MessageConsumer
|
protected void |
addProducer(MessageProducer mp)
Called here and by sub-classes.
|
private void |
checkClientID() |
private void |
checkCLMessageProducer(MessageProducer mp) |
protected void |
checkClosed()
Checks if the session is closed.
|
(package private) void |
checkConsumers(String agentId)
Called by Connection (i.e. temporary destinations deletion)
|
private void |
checkSessionMode(int expectedSessionMode)
Checks the session mode.
|
private void |
checkShared(Topic topic,
String sharedSubscriptionName,
String selector) |
(package private) boolean |
checkThread() |
private void |
checkThreadOfControl()
Checks if the calling thread is the thread of control.
|
void |
close()
API method.
|
(package private) void |
closeBrowser(QueueBrowser qb)
Called by Queue browser.
|
(package private) void |
closeConsumer(MessageConsumer mc)
Called by MessageConsumer.
|
(package private) void |
closeProducer(MessageProducer mp)
Called by MessageProducer.
|
void |
commit()
API method.
|
QueueBrowser |
createBrowser(Queue queue)
API method.
|
QueueBrowser |
createBrowser(Queue queue,
String selector)
API method.
|
BytesMessage |
createBytesMessage()
API method.
|
MessageConsumer |
createConsumer(Destination dest)
API method.
|
MessageConsumer |
createConsumer(Destination dest,
String selector)
API method.
|
MessageConsumer |
createConsumer(Destination dest,
String selector,
boolean noLocal)
API method.
|
private String |
createDestination(byte type,
String name)
Create a destination with the given name and type.
|
MessageConsumer |
createDurableConsumer(Topic topic,
String name)
API 2.0 method.
|
MessageConsumer |
createDurableConsumer(Topic topic,
String name,
String selector,
boolean noLocal)
API 2.0 method.
|
TopicSubscriber |
createDurableSubscriber(Topic topic,
String name)
API method.
|
TopicSubscriber |
createDurableSubscriber(Topic topic,
String name,
String selector,
boolean noLocal)
API method.
|
MapMessage |
createMapMessage()
API method.
|
Message |
createMessage()
API method.
|
ObjectMessage |
createObjectMessage()
API method.
|
ObjectMessage |
createObjectMessage(Serializable object)
API method.
|
MessageProducer |
createProducer(Destination dest)
API method.
|
Queue |
createQueue(String name)
This method allows to create or retrieve a Queue with the given name
on the local server.
|
MessageConsumer |
createSharedConsumer(Topic topic,
String sharedSubscriptionName)
API 2.0 method.
|
MessageConsumer |
createSharedConsumer(Topic topic,
String sharedSubscriptionName,
String selector)
API 2.0 method.
|
MessageConsumer |
createSharedDurableConsumer(Topic topic,
String name)
API 2.0 method.
|
MessageConsumer |
createSharedDurableConsumer(Topic topic,
String name,
String selector)
API 2.0 method.
|
StreamMessage |
createStreamMessage()
API method.
|
TemporaryQueue |
createTemporaryQueue()
API method.
|
TemporaryTopic |
createTemporaryTopic()
API method.
|
TextMessage |
createTextMessage()
API method.
|
TextMessage |
createTextMessage(String text)
API method.
|
Topic |
createTopic(String name)
This method allows to create or retrieve a Topic with the given name
on the local server.
|
private void |
deny()
Method denying the received messages.
|
private void |
denyMessage(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 void |
doAcknowledge()
Method acknowledging the received messages.
|
(package private) void |
doClose() |
private void |
doRecover() |
private void |
doStart() |
private void |
doStop() |
int |
getAcknowledgeMode()
API method.
|
int |
getCompressedMinSize()
Get the compressedMinSize for this session.
|
int |
getCompressionLevel()
Get the compression level for this session.
|
(package private) Connection |
getConnection() |
(package private) String |
getId() |
String |
getJMXBeanName()
Returns the MBean name.
|
private MessageConsumer |
getMessageConsumer(String sharedSubscriptionName) |
(package private) MessageConsumerListener |
getMessageConsumerListener(String targetName) |
MessageListener |
getMessageListener()
API method.
|
int |
getQueueMessageReadMax()
Get the maximum number of messages that can be read at once from a queue
for this Session.
|
(package private) RequestMultiplexer |
getRequestMultiplexer() |
String |
getRequestStatus()
The status of the current request.
|
String |
getSessionMode()
The way the session is used.
|
String |
getStatus()
Status of the session
|
int |
getTopicAckBufferMax()
Get the maximum number of acknowledgements that can be buffered when
using Session.DUPS_OK_ACKNOWLEDGE mode for this session.
|
int |
getTopicActivationThreshold()
Get the threshold of activation for this session.
|
int |
getTopicPassivationThreshold()
Get the threshold of passivation for this session.
|
boolean |
getTransacted()
API method.
|
boolean |
isAsyncSend()
Indicates whether the messages produced are asynchronously sent
or not (without or with acknowledgment).
|
boolean |
isAsyncSub()
Indicates whether the subscription request is asynchronously handled
or not.
|
boolean |
isAutoAck()
true if the session's acknowledgements are automatic. |
boolean |
isImplicitAck()
Indicates whether the messages consumed are implicitly acknowledged
or not.
|
boolean |
isStarted() |
(package private) void |
onMessage(Message msg)
Called by ConnectionConsumer in order to distribute a message through the
method run().
|
(package private) void |
onMessage(Message momMsg,
MessageConsumerListener mcl)
Called by onMessages()
|
private void |
onMessages(Session.MessageListenerContext ctx)
Called by SessionDaemon.
|
private void |
postReceive()
Final stage after calling the reply has been returned
by the roxy.
|
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.
|
private void |
prepareSend(Destination dest,
Message msg)
Method called by message producers when producing a message for
preparing the session to later commit it.
|
private void |
preReceive(MessageConsumer mc)
First stage before calling the proxy and waiting
for the reply.
|
(package private) void |
pushMessages(SingleSessionConsumer consumerListener,
ConsumerMessages messages)
Called by MessageConsumerListener (demultiplexer thread
from RequestMultiplexer) in order to distribute messages
to a message consumer.
|
(package private) void |
putMessageConsumerListener(String targetName,
MessageConsumerListener mcl) |
(package private) Message |
receive(long requestTimeToLive,
long waitTimeOut,
MessageConsumer mc,
String targetName,
String selector,
boolean queueMode)
Called by MessageConsumer.
|
void |
recover()
API method.
|
String |
registerMBean() |
(package private) MessageConsumerListener |
removeMessageConsumerListener(String targetName) |
(package private) void |
removeMessageListener(MessageConsumerListener mcl,
boolean check)
Called by MessageConsumer.
|
void |
rollback()
API method.
|
void |
run()
API method.
|
(package private) void |
send(Destination dest,
Message msg,
int deliveryMode,
int priority,
long timeToLive,
boolean timestampDisabled,
long deliveryDelay,
CompletionListener completionListener,
MessageProducer messageProducer)
Called by MessageProducer.
|
void |
setAsyncSend(boolean asyncSend)
Sets asynchronously sending for this session.
|
void |
setAsyncSub(boolean asyncSub)
Sets asynchronous subscription for this session.
|
void |
setCompressedMinSize(int compressedMinSize)
Sets the minimum size beyond which the message body is compressed in this session.
|
void |
setCompressionLevel(int compressionLevel)
Set the compression level for this session.
|
void |
setImplicitAck(boolean implicitAck)
Sets implicit acknowledge for this session.
|
(package private) void |
setMessageConsumerListener(MessageConsumerListener mcl)
Called by MultiSessionConsumer
ASF mode
|
void |
setMessageListener(MessageListener listener)
API method.
|
void |
setQueueMessageReadMax(int queueMessageReadMax)
Set the maximum number of messages that can be read at once from a queue
for this Session.
|
private void |
setRequestStatus(int requestStatus)
Sets the request status.
|
private void |
setSessionMode(int sessionMode)
Sets the session mode.
|
private void |
setStatus(int status)
Sets the status of the session.
|
void |
setTopicAckBufferMax(int topicAckBufferMax)
Set the maximum number of acknowledgements that can be buffered when
using Session.DUPS_OK_ACKNOWLEDGE mode for this session.
|
void |
setTopicActivationThreshold(int topicActivationThreshold)
Set the threshold of activation for this session.
|
void |
setTopicPassivationThreshold(int topicPassivationThreshold)
Set the threshold of passivation for this session.
|
void |
setTransacted(boolean t)
set transacted.
|
(package private) void |
start()
Starts the asynchronous deliveries in the session.
|
(package private) void |
stop()
Stops the asynchronous deliveries processing in the session.
|
(package private) AbstractJmsReply |
syncRequest(AbstractJmsRequest request)
Called by MessageConsumer.
|
String |
toString()
Returns a String image of this session.
|
void |
unregisterMBean() |
void |
unsubscribe(String name)
API method.
|
public static org.objectweb.util.monolog.api.Logger logger
public static org.objectweb.util.monolog.api.Logger trace
public static int INDIVIDUAL_ACKNOWLEDGE
private Session.SessionCloseTask closingTask
private boolean scheduled
true
if the session's transaction is scheduled.protected MessageListener messageListener
private String ident
private Connection cnx
boolean transacted
true
if the session is transacted.private int acknowledgeMode
private boolean autoAck
true
if the session's acknowledgements are automatic.private Vector<MessageConsumer> consumers
private Vector producers
private Vector browsers
private Queue repliesIn
private Session.SessionDaemon daemon
private int listenerCount
Hashtable sendings
ProducerMessages
holding producers'
messages and destinated to be sent at commit.
Key: destination name
Object: ProducerMessages
Hashtable deliveries
Key: destination or subscription name
Object: MessageAcks
instance
CompletionListener listener
private RequestMultiplexer mtpx
private Requestor requestor
private Requestor receiveRequestor
private boolean recover
private boolean toClose
private int status
private int sessionMode
private int requestStatus
private MessageConsumer pendingMessageConsumer
private Thread singleThreadOfControl
private Session.Closer closer
private boolean implicitAck
FactoryParameters.implicitAck
private boolean asyncSend
FactoryParameters.asyncSend
private int queueMessageReadMax
This attribute is inherited from Connection at initialization.
FactoryParameters.queueMessageReadMax
private int topicAckBufferMax
This attribute is inherited from Connection at initialization.
FactoryParameters.topicAckBufferMax
private int topicPassivationThreshold
This attribute is inherited from Connection at initialization, default value is Integer.MAX_VALUE.
FactoryParameters.topicPassivationThreshold
private int topicActivationThreshold
This attribute is inherited from Connection at initialization, default value is 0.
FactoryParameters.topicActivationThreshold
private int compressedMinSize
compressedMinSize
,
this message body is compressed.
This attribute is inherited from Connection at initialization default value is 0 no compression
FactoryParameters.compressedMinSize
private int compressionLevel
This attribute is inherited from Connection at initialization default value is Deflater.BEST_SPEED (1)
FactoryParameters.compressionLevel
private boolean asyncSub
Default value is false, the subscription is handled synchronously so the topic must be accessible.
private MessageConsumerListener messageConsumerListener
private List inInterceptors
private List outInterceptors
Map<String,MessageConsumerListener> messageConsumerListeners
Session(Connection cnx, boolean transacted, int acknowledgeMode, RequestMultiplexer mtpx) throws JMSException
cnx
- The connection the session belongs to.transacted
- true
for a transacted session.acknowledgeMode
- 1 (auto), 2 (client), 3 (dups ok), 4 (individual).JMSException
- In case of an invalid acknowledge mode.boolean checkThread()
public boolean isImplicitAck()
This attribute is inherited from Connection at initialization, by default false.
isImplicitAck
in interface SessionMBean
#implicitAck
public void setImplicitAck(boolean implicitAck)
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.
implicitAck
- if true sets implicit acknowledge for this session.public boolean isAsyncSend()
This attribute is inherited from Connection at initialization, by default false.
isAsyncSend
in interface SessionMBean
#asyncSend
public void setAsyncSend(boolean asyncSend)
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.
asyncSend
- if true sets asynchronous sending for this session.FactoryParameters.asyncSend
public final int getQueueMessageReadMax()
This attribute is inherited from Connection at initialization, default value is 1.
getQueueMessageReadMax
in interface SessionMBean
FactoryParameters.queueMessageReadMax
public void setQueueMessageReadMax(int queueMessageReadMax)
This attribute is inherited from Connection at initialization, default value is 1.
queueMessageReadMax
- The maximum number of messages that can be
read at once from a queue.FactoryParameters.queueMessageReadMax
public final int getTopicAckBufferMax()
This attribute is inherited from Connection at initialization.
getTopicAckBufferMax
in interface SessionMBean
FactoryParameters.topicAckBufferMax
public void setTopicAckBufferMax(int topicAckBufferMax)
This attribute is inherited from Connection at initialization.
topicAckBufferMax
- The Maximum number of acknowledgements that
can be buffered in Session.DUPS_OK_ACKNOWLEDGE
mode.FactoryParameters.topicAckBufferMax
public final int getTopicPassivationThreshold()
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.
getTopicPassivationThreshold
in interface SessionMBean
FactoryParameters.topicPassivationThreshold
public void setTopicPassivationThreshold(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.
topicPassivationThreshold
- The maximum messages number over which
the subscription is passivated.FactoryParameters.topicPassivationThreshold
public final int getTopicActivationThreshold()
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.
getTopicActivationThreshold
in interface SessionMBean
FactoryParameters.topicActivationThreshold
public void setTopicActivationThreshold(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.
topicActivationThreshold
- The minimum messages number below which
the subscription is activated.FactoryParameters.topicActivationThreshold
public final int getCompressedMinSize()
The minimum message body size before a message body compression.
This attribute is inherited from Connection at initialization, default value is 0 no compression
getCompressedMinSize
in interface SessionMBean
FactoryParameters.compressedMinSize
public final void setCompressedMinSize(int compressedMinSize)
compressedMinSize
- The minimum size before a message body compression.FactoryParameters.compressedMinSize
public final int getCompressionLevel()
This attribute is inherited from FactoryParameters, default value is Deflater.BEST_SPEED (1).
getCompressionLevel
in interface SessionMBean
FactoryParameters.compressionLevel
public final void setCompressionLevel(int compressionLevel)
This attribute is inherited from FactoryParameters, default value is Deflater.BEST_SPEED (1). This method can overload this attribute.
The
- compression levelFactoryParameters.compressionLevel
public boolean isAsyncSub()
Default value is false, the subscription is handled synchronously so the topic must be accessible.
isAsyncSub
in interface SessionMBean
public void setAsyncSub(boolean asyncSub)
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.
asyncSub
- if true sets asynchronous subscription for this session.MessageConsumerListener getMessageConsumerListener(String targetName)
void putMessageConsumerListener(String targetName, MessageConsumerListener mcl)
MessageConsumerListener removeMessageConsumerListener(String targetName)
public String getJMXBeanName()
public String registerMBean()
public void unregisterMBean()
private void setStatus(int status)
public boolean isStarted()
isStarted
in interface SessionMBean
public String getStatus()
SessionMBean
getStatus
in interface SessionMBean
private void setSessionMode(int sessionMode)
public String getSessionMode()
SessionMBean
getSessionMode
in interface SessionMBean
private void setRequestStatus(int requestStatus)
public String getRequestStatus()
SessionMBean
getRequestStatus
in interface SessionMBean
protected void checkClosed() throws IllegalStateException
IllegalStateException
private void checkThreadOfControl() throws IllegalStateException
IllegalStateException
private void checkSessionMode(int expectedSessionMode) throws IllegalStateException
expectedSessionMode
- the expected session mode.IllegalStateException
private void checkClientID() throws JMSException
JMSException
public String toString()
public final int getAcknowledgeMode() throws JMSException
getAcknowledgeMode
in interface Session
getAcknowledgeMode
in interface SessionMBean
JMSException
- Actually never thrown.public final boolean getTransacted() throws JMSException
getTransacted
in interface Session
getTransacted
in interface SessionMBean
IllegalStateException
- If the session is closed.JMSException
public void setTransacted(boolean t)
public void setMessageListener(MessageListener listener) throws JMSException
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.
setMessageListener
in interface Session
listener
- the message listener to associate with this session.JMSException
- Actually never thrown.public MessageListener getMessageListener() throws JMSException
getMessageListener
in interface Session
JMSException
- Actually never thrown.public Message createMessage() throws JMSException
createMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
Message
public TextMessage createTextMessage() throws JMSException
createTextMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
TextMessage
public TextMessage createTextMessage(String text) throws JMSException
createTextMessage
in interface Session
text
- the string to use to initialize this message.IllegalStateException
- If the session is closed.JMSException
TextMessage
public BytesMessage createBytesMessage() throws JMSException
BytesMessage
object, a BytesMessage object could be used to send
a message containing a stream of uninterpreted bytes.createBytesMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
BytesMessage
public MapMessage createMapMessage() throws JMSException
MapMessage
object, a MapMessage object is used to send a set
of name-value pairs, where names are String objects and values are primitive values.createMapMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
MapMessage
public ObjectMessage createObjectMessage() throws JMSException
createObjectMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
ObjectMessage
public ObjectMessage createObjectMessage(Serializable object) throws JMSException
createObjectMessage
in interface Session
object
- the object to use to initialize this message.IllegalStateException
- If the session is closed.JMSException
ObjectMessage
public StreamMessage createStreamMessage() throws JMSException
createStreamMessage
in interface Session
IllegalStateException
- If the session is closed.JMSException
StreamMessage
public QueueBrowser createBrowser(Queue queue, String selector) throws JMSException
createBrowser
in interface Session
queue
- the queue to browseselector
- the expression allowing to filter messagesIllegalStateException
- if the session is closed.InvalidDestinationException
- if an invalid destination is specified.InvalidSelectorException
- if the message selector is invalid.JMSException
public QueueBrowser createBrowser(Queue queue) throws JMSException
createBrowser
in interface Session
queue
- the queue to browseIllegalStateException
- if the session is closed.InvalidDestinationException
- if an invalid destination is specified.JMSException
public MessageProducer createProducer(Destination dest) throws JMSException
createProducer
in interface Session
dest
- the Destination to send to, or null if this is a producer which does not have
a specified destination.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.public MessageConsumer createConsumer(Destination dest, String selector, boolean noLocal) throws JMSException
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.
createConsumer
in interface Session
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.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.public MessageConsumer createConsumer(Destination dest, String selector) throws JMSException
createConsumer
in interface Session
dest
- the Destination to access.selector
- The selector allowing to filter messages.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.public MessageConsumer createConsumer(Destination dest) throws JMSException
createConsumer
in interface Session
dest
- the Destination to access.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.public TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal) throws JMSException
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.
createDurableSubscriber
in interface Session
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.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.public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
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.
createDurableSubscriber
in interface Session
topic
- the non-temporary Topic to subscribe to.name
- the name used to identify this subscription.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.public Queue createQueue(String name) throws JMSException
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.
createQueue
in interface Session
name
- the name of this queue.IllegalStateException
- If the session is closed.JMSException
- If the topic creation failed.Queue
public Topic createTopic(String name) throws JMSException
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.
createTopic
in interface Session
name
- the name of this topic.IllegalStateException
- If the session is closed.JMSException
- If the topic creation failed.Topic
private String createDestination(byte type, String name) throws JMSException
type
- the type of the destination to create.name
- the name of the destination to create.JMSException
public TemporaryQueue createTemporaryQueue() throws JMSException
createTemporaryQueue
in interface Session
IllegalStateException
- If the session is closed or if the
connection is broken.JMSException
- If the request fails for any other reason.TemporaryQueue
public TemporaryTopic createTemporaryTopic() throws JMSException
createTemporaryTopic
in interface Session
IllegalStateException
- If the session is closed or if the
connection is broken.JMSException
- If the request fails for any other reason.TemporaryTopic
public void run()
void setMessageConsumerListener(MessageConsumerListener mcl)
public void commit() throws JMSException
commit
in interface Session
IllegalStateException
- If the session is closed, or not
transacted, or if the connection is broken.JMSException
public void rollback() throws JMSException
rollback
in interface Session
IllegalStateException
- If the session is closed, or not
transacted.JMSException
public void recover() throws JMSException
recover
in interface Session
IllegalStateException
- If the session is closed, or transacted.JMSException
private void doRecover() throws JMSException
JMSException
public void unsubscribe(String name) throws JMSException
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.
unsubscribe
in interface Session
unsubscribe
in interface SessionMBean
name
- the name used to identify this subscription.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.public void close() throws JMSException
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.
close
in interface Session
close
in interface SessionMBean
JMSException
- if the JMS provider fails to close the session due to some internal error.void doClose() throws JMSException
JMSException
void start()
This method is called by a started connection.
private void doStart()
void stop()
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 he Session.close()
and Connection.stop()
methods, which first empties the
session's deliveries and forbid any further push.
private void doStop()
private void prepareSend(Destination dest, Message msg) throws JMSException
dest
- The destination the message is destinated to.msg
- The message.JMSException
private void prepareAck(String name, String id, boolean queueMode)
name
- Name of the destination or of the proxy subscription
the message comes from.id
- Identifier of the consumed message.queueMode
- true
if the message consumed comes from
a queue.void acknowledge() throws JMSException
JMSException
private void doAcknowledge() throws JMSException
JMSException
void acknowledge(Destination dest, String msgId) throws JMSException
JMSException
private void deny() throws JMSException
JMSException
Message receive(long requestTimeToLive, long waitTimeOut, MessageConsumer mc, String targetName, String selector, boolean queueMode) throws JMSException
JMSException
private void preReceive(MessageConsumer mc) throws JMSException
JMSException
private void postReceive()
protected void addConsumer(MessageConsumer mc)
void closeConsumer(MessageConsumer mc)
void checkConsumers(String agentId) throws JMSException
JMSException
private void checkCLMessageProducer(MessageProducer mp) throws IllegalStateException
IllegalStateException
protected void addProducer(MessageProducer mp)
void closeProducer(MessageProducer mp) throws IllegalStateException
IllegalStateException
void closeBrowser(QueueBrowser qb)
MessageConsumerListener addMessageListener(MessageConsumerListener mcl, boolean check) throws JMSException
JMSException
void removeMessageListener(MessageConsumerListener mcl, boolean check) throws JMSException
JMSException
void pushMessages(SingleSessionConsumer consumerListener, ConsumerMessages messages)
void onMessage(Message msg)
private void denyMessage(String targetName, String msgId, boolean queueMode, boolean redelivered) throws JMSException
JMSException
private void onMessages(Session.MessageListenerContext ctx) throws JMSException
JMSException
void onMessage(Message momMsg, MessageConsumerListener mcl) throws JMSException
JMSException
void send(Destination dest, Message msg, int deliveryMode, int priority, long timeToLive, boolean timestampDisabled, long deliveryDelay, CompletionListener completionListener, MessageProducer messageProducer) throws JMSException
JMSException
AbstractJmsReply syncRequest(AbstractJmsRequest request) throws JMSException
JMSException
final Connection getConnection()
final String getId()
final RequestMultiplexer getRequestMultiplexer()
public final boolean isAutoAck()
SessionMBean
true
if the session's acknowledgements are automatic.isAutoAck
in interface SessionMBean
private MessageConsumer getMessageConsumer(String sharedSubscriptionName)
private void checkShared(Topic topic, String sharedSubscriptionName, String selector) throws JMSException
JMSException
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException
JMSException
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String selector) throws JMSException
JMSException
public MessageConsumer createDurableConsumer(Topic topic, String name) throws JMSException
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.
topic
- the non-temporary Topic to subscribe to.name
- the name used to identify this subscription.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.public MessageConsumer createDurableConsumer(Topic topic, String name, String selector, boolean noLocal) throws JMSException
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.
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.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.public MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException
JMSException
public MessageConsumer createSharedDurableConsumer(Topic topic, String name, String selector) throws JMSException
JMSException
Copyright © 2016 ScalAgent D.T.. All Rights Reserved.