|
|||||||||
| Home >> All >> org >> [ activemq overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.activemq
Class ActiveMQSession

java.lang.Objectorg.activemq.ActiveMQSession
- All Implemented Interfaces:
- ActiveMQMessageDispatcher, org.activemq.message.MessageAcknowledge, javax.jms.QueueSession, java.lang.Runnable, javax.jms.Session, org.activemq.management.StatsCapable, javax.jms.TopicSession
- Direct Known Subclasses:
- ActiveMQXASession
- public class ActiveMQSession
- extends java.lang.Object
- implements javax.jms.Session, javax.jms.QueueSession, javax.jms.TopicSession, ActiveMQMessageDispatcher, org.activemq.message.MessageAcknowledge, org.activemq.management.StatsCapable
- extends java.lang.Object
A Session object is a single-threaded context for producing and consuming messages. Although it may
allocate provider resources outside the Java virtual machine (JVM), it is considered a lightweight JMS object.
A session serves several purposes:
- It is a factory for its message producers and consumers.
- It supplies provider-optimized message factories.
- It is a factory for
TemporaryTopicsandTemporaryQueues. - It provides a way to create
QueueorTopicobjects for those clients that need to dynamically manipulate provider-specific destination names. - It supports a single series of transactions that combine work spanning its producers and consumers into atomic units.
- 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
QueueBrowsers.
A session can create and service multiple message producers and consumers.
One typical use is to have a thread block on a synchronous MessageConsumer until a message arrives.
The thread may then use one or more of the Session'sMessageProducers.
If a client desires to have one thread produce messages while others consume them, the client should use a separate session for its producing thread.
Once a connection has been started, any session with one or more registered message listeners is dedicated to the
thread of control that delivers messages to it. It is erroneous for client code to use this session or any of its
constituent objects from another thread of control. The only exception to this rule is the use of the session or
connection close method.
It should be easy for most clients to partition their work naturally into sessions. This model allows clients to start simply and incrementally add message processing complexity as their need for concurrency grows.
The close method is the only session method that can be called while some other session method is
being executed in another thread.
A session may be specified as transacted. Each transacted session supports a single series of transactions. Each transaction groups a set of message sends and a set of message receives into an atomic unit of work. In effect, transactions organize a session's input message stream and output message stream into series of atomic units. When a transaction commits, its atomic unit of input is acknowledged and its associated atomic unit of output is sent. If a transaction rollback is done, the transaction's sent messages are destroyed and the session's input is automatically recovered.
The content of a transaction's input and output units is simply those messages that have been produced and consumed within the session's current transaction.
A transaction is completed using either its session's commit method or its session's rollback
method. The completion of a session's current transaction automatically begins the next. The result is that a
transacted session always has a current transaction within which its work is done.
The Java Transaction Service (JTS) or some other transaction monitor may be used to combine a session's transaction
with transactions on other resources (databases, other JMS sessions, etc.). Since Java distributed transactions are
controlled via the Java Transaction API (JTA), use of the session's commit and rollback
methods in this context is prohibited.
The JMS API does not require support for JTA; however, it does define how a provider supplies this support.
Although it is also possible for a JMS client to handle distributed transactions directly, it is unlikely that many JMS clients will do this. Support for JTA in the JMS API is targeted at systems vendors who will be integrating the JMS API into their application server products.
- Version:
- $Revision: 1.1.1.1 $
| Nested Class Summary | |
static interface |
ActiveMQSession.DeliveryListener
|
| Field Summary | |
protected int |
acknowledgeMode
|
protected boolean |
closed
|
private org.activemq.io.util.ByteArrayCompression |
compression
|
protected ActiveMQConnection |
connection
|
protected static int |
CONSUMER_DISPATCH_ASYNC
|
protected static int |
CONSUMER_DISPATCH_SYNC
|
protected static int |
CONSUMER_DISPATCH_UNSET
|
private int |
consumerDispatchState
|
protected CopyOnWriteArrayList |
consumers
|
private org.activemq.service.impl.DefaultQueueList |
deliveredMessages
|
private ActiveMQSession.DeliveryListener |
deliveryListener
|
private boolean |
internalSession
|
private static org.apache.commons.logging.Log |
log
|
private ActiveMQSessionExecutor |
messageExecutor
|
private javax.jms.MessageListener |
messageListener
|
protected CopyOnWriteArrayList |
producers
|
private short |
sessionId
|
private SynchronizedBoolean |
started
|
private long |
startTime
|
private org.activemq.management.JMSSessionStatsImpl |
stats
|
private org.activemq.util.IdGenerator |
temporaryDestinationGenerator
|
private TransactionContext |
transactionContext
|
| Fields inherited from interface javax.jms.Session |
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED |
| Constructor Summary | |
protected |
ActiveMQSession(ActiveMQConnection theConnection,
int theAcknowledgeMode)
Construct the Session |
protected |
ActiveMQSession(ActiveMQConnection theConnection,
int theAcknowledgeMode,
boolean optimizedDispatch)
Construct the Session |
| Method Summary | |
void |
acknowledge(org.activemq.message.ActiveMQMessage caller)
Acknowledges all consumed messages of the session of this consumed message. |
protected void |
addConsumer(ActiveMQMessageConsumer consumer)
|
protected void |
addProducer(ActiveMQMessageProducer producer)
|
protected void |
afterMessageDelivered(boolean sendAcknowledge,
org.activemq.message.ActiveMQMessage message,
boolean messageConsumed,
boolean messageExpired,
boolean beforeCalled)
|
protected void |
beforeMessageDelivered(org.activemq.message.ActiveMQMessage message)
|
protected void |
checkClosed()
|
void |
clearDeliveredMessages()
|
protected void |
clearMessagesInProgress()
|
void |
close()
Closes the session. |
void |
commit()
Commits all messages done in this transaction and releases any locks currently held. |
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue)
Creates a QueueBrowser object to peek at the messages on the specified queue. |
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue,
java.lang.String messageSelector)
Creates a QueueBrowser object to peek at the messages on the specified queue using a message
selector. |
javax.jms.BytesMessage |
createBytesMessage()
Creates a BytesMessage object. |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination)
Creates a MessageConsumer for the specified destination. |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector)
Creates a MessageConsumer for the specified destination, using a message selector. |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector,
boolean NoLocal)
Creates MessageConsumer for the specified destination, using a message selector. |
protected org.activemq.message.ConsumerInfo |
createConsumerInfo(ActiveMQMessageConsumer consumer)
|
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name)
Creates a durable subscriber to the specified topic. |
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name,
java.lang.String messageSelector,
boolean noLocal)
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. |
javax.jms.MapMessage |
createMapMessage()
Creates a MapMessage object. |
javax.jms.Message |
createMessage()
Creates a Message object. |
javax.jms.ObjectMessage |
createObjectMessage()
Creates an ObjectMessage object. |
javax.jms.ObjectMessage |
createObjectMessage(java.io.Serializable object)
Creates an initialized ObjectMessage object. |
javax.jms.MessageProducer |
createProducer(javax.jms.Destination destination)
Creates a MessageProducer to send messages to the specified destination. |
protected org.activemq.message.ProducerInfo |
createProducerInfo(ActiveMQMessageProducer producer)
|
javax.jms.TopicPublisher |
createPublisher(javax.jms.Topic topic)
Creates a publisher for the specified topic. |
javax.jms.Queue |
createQueue(java.lang.String queueName)
Creates a queue identity given a Queue name. |
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue)
Creates a QueueReceiver object to receive messages from the specified queue. |
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue,
java.lang.String messageSelector)
Creates a QueueReceiver object to receive messages from the specified queue using a message
selector. |
javax.jms.QueueSender |
createSender(javax.jms.Queue queue)
Creates a QueueSender object to send messages to the specified queue. |
javax.jms.StreamMessage |
createStreamMessage()
Creates a StreamMessage object. |
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic)
Creates a nondurable subscriber to the specified topic. |
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic,
java.lang.String messageSelector,
boolean noLocal)
Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it. |
javax.jms.TemporaryQueue |
createTemporaryQueue()
Creates a TemporaryQueue object. |
javax.jms.TemporaryTopic |
createTemporaryTopic()
Creates a TemporaryTopic object. |
javax.jms.TextMessage |
createTextMessage()
Creates a TextMessage object. |
javax.jms.TextMessage |
createTextMessage(java.lang.String text)
Creates an initialized TextMessage object. |
javax.jms.Topic |
createTopic(java.lang.String topicName)
Creates a topic identity given a Topic name. |
private void |
deliver(org.activemq.message.ActiveMQMessage message)
Delivers a message to the messageListern |
void |
dispatch(org.activemq.message.ActiveMQMessage message)
Dispatch an ActiveMQMessage |
protected void |
doAcknowledge(boolean isClosing)
|
protected void |
doClose()
|
private void |
doSendMessageAck(org.activemq.message.ActiveMQMessage message,
boolean messageConsumed,
boolean messageExpired)
|
protected void |
doStartTransaction()
Send TransactionInfo to indicate transaction has started |
int |
getAcknowledgeMode()
Returns the acknowledgement mode of the session. |
ActiveMQSession.DeliveryListener |
getDeliveryListener()
|
javax.jms.MessageListener |
getMessageListener()
Returns the session's distinguished message listener (optional). |
protected short |
getSessionId()
|
org.activemq.management.JMSSessionStatsImpl |
getSessionStats()
|
protected long |
getStartTime()
|
org.activemq.management.StatsImpl |
getStats()
|
boolean |
getTransacted()
Indicates whether the session is in transacted mode. |
TransactionContext |
getTransactionContext()
|
java.util.List |
getUnconsumedMessages()
|
boolean |
hasUncomsumedMessages()
|
protected boolean |
isClientAcknowledge()
|
boolean |
isInternalSession()
|
boolean |
isTarget(org.activemq.message.ActiveMQMessage message)
Tests to see if the Message Dispatcher is a target for this message |
boolean |
isTransacted()
|
void |
recover()
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message. |
protected void |
redeliverUnacknowledgedMessages()
|
protected void |
redeliverUnacknowledgedMessages(boolean onlyDeliverTransientConsumed)
|
protected void |
removeConsumer(ActiveMQMessageConsumer consumer)
|
protected void |
removeProducer(ActiveMQMessageProducer producer)
|
void |
removeTemporaryDestination(org.activemq.message.ActiveMQDestination destination)
remove a temporary destination |
void |
rollback()
Rolls back any messages done in this transaction and releases any locks currently held. |
void |
run()
Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients. |
protected void |
send(ActiveMQMessageProducer producer,
javax.jms.Destination destination,
javax.jms.Message message,
int deliveryMode,
int priority,
long timeToLive,
boolean reuseMessageId)
send the message for dispatch by the broker |
private void |
sendMessageAck(org.activemq.message.ActiveMQMessage message,
boolean messageConsumed,
boolean messageExpired)
|
void |
setDeliveryListener(ActiveMQSession.DeliveryListener deliveryListener)
|
void |
setInternalSession(boolean internalSession)
|
void |
setMessageListener(javax.jms.MessageListener listener)
Sets the session's distinguished message listener (optional). |
protected void |
setSessionConsumerDispatchState(int value)
|
protected void |
setSessionId(short sessionId)
|
protected void |
setStartTime(long startTime)
|
void |
setTransactionContext(TransactionContext transactionContext)
|
protected void |
start()
Start this Session |
protected void |
stop()
Stop this Session |
void |
unsubscribe(java.lang.String name)
Unsubscribes a durable subscription that has been created by a client. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
CONSUMER_DISPATCH_UNSET
protected static final int CONSUMER_DISPATCH_UNSET
- See Also:
- Constant Field Values
CONSUMER_DISPATCH_ASYNC
protected static final int CONSUMER_DISPATCH_ASYNC
- See Also:
- Constant Field Values
CONSUMER_DISPATCH_SYNC
protected static final int CONSUMER_DISPATCH_SYNC
- See Also:
- Constant Field Values
log
private static final org.apache.commons.logging.Log log
connection
protected ActiveMQConnection connection
acknowledgeMode
protected int acknowledgeMode
consumers
protected CopyOnWriteArrayList consumers
producers
protected CopyOnWriteArrayList producers
temporaryDestinationGenerator
private org.activemq.util.IdGenerator temporaryDestinationGenerator
messageListener
private javax.jms.MessageListener messageListener
closed
protected boolean closed
started
private SynchronizedBoolean started
sessionId
private short sessionId
startTime
private long startTime
deliveredMessages
private org.activemq.service.impl.DefaultQueueList deliveredMessages
messageExecutor
private ActiveMQSessionExecutor messageExecutor
stats
private org.activemq.management.JMSSessionStatsImpl stats
consumerDispatchState
private int consumerDispatchState
compression
private org.activemq.io.util.ByteArrayCompression compression
transactionContext
private TransactionContext transactionContext
internalSession
private boolean internalSession
deliveryListener
private ActiveMQSession.DeliveryListener deliveryListener
| Constructor Detail |
ActiveMQSession
protected ActiveMQSession(ActiveMQConnection theConnection, int theAcknowledgeMode) throws javax.jms.JMSException
- Construct the Session
ActiveMQSession
protected ActiveMQSession(ActiveMQConnection theConnection, int theAcknowledgeMode, boolean optimizedDispatch) throws javax.jms.JMSException
- Construct the Session
| Method Detail |
setTransactionContext
public void setTransactionContext(TransactionContext transactionContext)
getTransactionContext
public TransactionContext getTransactionContext()
getStats
public org.activemq.management.StatsImpl getStats()
- Specified by:
getStatsin interfaceorg.activemq.management.StatsCapable
getSessionStats
public org.activemq.management.JMSSessionStatsImpl getSessionStats()
createBytesMessage
public javax.jms.BytesMessage createBytesMessage() throws javax.jms.JMSException
- Creates a
BytesMessageobject. ABytesMessageobject is used to send a message containing a stream of uninterpreted bytes.- Specified by:
createBytesMessagein interfacejavax.jms.Session
createMapMessage
public javax.jms.MapMessage createMapMessage() throws javax.jms.JMSException
- Creates a
MapMessageobject. AMapMessageobject is used to send a self-defining set of name-value pairs, where names areStringobjects and values are primitive values in the Java programming language.- Specified by:
createMapMessagein interfacejavax.jms.Session
createMessage
public javax.jms.Message createMessage() throws javax.jms.JMSException
- Creates a
Messageobject. TheMessageinterface is the root interface of all JMS messages. AMessageobject holds all the standard message header information. It can be sent when a message containing only header information is sufficient.- Specified by:
createMessagein interfacejavax.jms.Session
createObjectMessage
public javax.jms.ObjectMessage createObjectMessage() throws javax.jms.JMSException
- Creates an
ObjectMessageobject. AnObjectMessageobject is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessagein interfacejavax.jms.Session
createObjectMessage
public javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object) throws javax.jms.JMSException
- Creates an initialized
ObjectMessageobject. AnObjectMessageobject is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessagein interfacejavax.jms.Session
createStreamMessage
public javax.jms.StreamMessage createStreamMessage() throws javax.jms.JMSException
- Creates a
StreamMessageobject. AStreamMessageobject is used to send a self-defining stream of primitive values in the Java programming language.- Specified by:
createStreamMessagein interfacejavax.jms.Session
createTextMessage
public javax.jms.TextMessage createTextMessage() throws javax.jms.JMSException
- Creates a
TextMessageobject. ATextMessageobject is used to send a message containing aStringobject.- Specified by:
createTextMessagein interfacejavax.jms.Session
createTextMessage
public javax.jms.TextMessage createTextMessage(java.lang.String text) throws javax.jms.JMSException
- Creates an initialized
TextMessageobject. ATextMessageobject is used to send a message containing aString.- Specified by:
createTextMessagein interfacejavax.jms.Session
getTransacted
public boolean getTransacted()
throws javax.jms.JMSException
- Indicates whether the session is in transacted mode.
- Specified by:
getTransactedin interfacejavax.jms.Session
getAcknowledgeMode
public int getAcknowledgeMode()
throws javax.jms.JMSException
- 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 interfacejavax.jms.Session
- Since:
- 1.1 exception JMSException if there is some internal error.
commit
public void commit()
throws javax.jms.JMSException
- Commits all messages done in this transaction and releases any locks currently held.
- Specified by:
commitin interfacejavax.jms.Session
rollback
public void rollback()
throws javax.jms.JMSException
- Rolls back any messages done in this transaction and releases any locks currently held.
- Specified by:
rollbackin interfacejavax.jms.Session
clearDeliveredMessages
public void clearDeliveredMessages()
close
public void close()
throws javax.jms.JMSException
- Closes the session.
Since a provider may allocate some resources on behalf of a session outside the JVM, clients should close the resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
There is no need to close the producers and consumers of a closed session.
This call will block until a
receivecall or message listener in progress has completed. A blocked message consumerreceivecall returnsnullwhen this session is closed.Closing a transacted session must roll back the transaction in progress.
This method is the only
Sessionmethod that can be called concurrently.Invoking any other
Sessionmethod on a closed session must throw aJMSException.IllegalStateException. Closing a closed session must not throw an exception.- Specified by:
closein interfacejavax.jms.Session
doClose
protected void doClose()
throws javax.jms.JMSException
checkClosed
protected void checkClosed()
throws javax.jms.IllegalStateException
recover
public void recover()
throws javax.jms.JMSException
- Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.
All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client.
Restarting a session causes it to take the following actions:
- Stop message delivery
- Mark all messages that might have been delivered but not acknowledged as "redelivered"
- Restart the delivery sequence including all unacknowledged messages that had been previously delivered. Redelivered messages do not have to be delivered in exactly their original delivery order.
- Specified by:
recoverin interfacejavax.jms.Session
getMessageListener
public javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
- Returns the session's distinguished message listener (optional).
- Specified by:
getMessageListenerin interfacejavax.jms.Session
setMessageListener
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
- Sets the session's distinguished message listener (optional).
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.
This is an expert facility not used by regular JMS clients.
- Specified by:
setMessageListenerin interfacejavax.jms.Session
run
public void run()
- Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients.
- Specified by:
runin interfacejavax.jms.Session
deliver
private void deliver(org.activemq.message.ActiveMQMessage message)
- Delivers a message to the messageListern
createProducer
public javax.jms.MessageProducer createProducer(javax.jms.Destination destination) throws javax.jms.JMSException
- Creates a
MessageProducerto send messages to the specified destination.A client uses a
MessageProducerobject to send messages to a destination. SinceQueueandTopicboth inherit fromDestination, they can be used in the destination parameter to create aMessageProducerobject.- Specified by:
createProducerin interfacejavax.jms.Session
- Since:
- 1.1
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
- Creates a
MessageConsumerfor the specified destination. SinceQueueandTopicboth inherit fromDestination, they can be used in the destination parameter to create aMessageConsumer.- Specified by:
createConsumerin interfacejavax.jms.Session
- Since:
- 1.1
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector) throws javax.jms.JMSException
- Creates a
MessageConsumerfor the specified destination, using a message selector. SinceQueueandTopicboth inherit fromDestination, they can be used in the destination parameter to create aMessageConsumer.A client uses a
MessageConsumerobject to receive messages that have been sent to a destination.- Specified by:
createConsumerin interfacejavax.jms.Session
- Since:
- 1.1
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector, boolean NoLocal) throws javax.jms.JMSException
- Creates
MessageConsumerfor the specified destination, using a message selector. This method can specify whether messages published by its own connection should be delivered to it, if the destination is a topic.Since
QueueandTopicboth inherit fromDestination, they can be used in the destination parameter to create aMessageConsumer.A client uses a
MessageConsumerobject to receive messages that have been published to a destination.In some cases, a connection may both publish and subscribe to a topic. The consumer
NoLocalattribute allows a consumer to inhibit the delivery of messages published by its own connection. The default value for this attribute is False. ThenoLocalvalue must be supported by destinations that are topics.- Specified by:
createConsumerin interfacejavax.jms.Session
- Since:
- 1.1
createQueue
public javax.jms.Queue createQueue(java.lang.String queueName) throws javax.jms.JMSException
- Creates a queue identity given a
Queuename.This facility is provided for the rare cases where clients need to dynamically manipulate queue identity. It allows the creation of a queue identity with a provider-specific name. Clients that depend on this ability are not portable.
Note that this method is not for creating the physical queue. The physical creation of queues is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary queues, which is accomplished with the
createTemporaryQueuemethod.- Specified by:
createQueuein interfacejavax.jms.Session
- Since:
- 1.1
createTopic
public javax.jms.Topic createTopic(java.lang.String topicName) throws javax.jms.JMSException
- Creates a topic identity given a
Topicname.This facility is provided for the rare cases where clients need to dynamically manipulate topic identity. This allows the creation of a topic identity with a provider-specific name. Clients that depend on this ability are not portable.
Note that this method is not for creating the physical topic. The physical creation of topics is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary topics, which is accomplished with the
createTemporaryTopicmethod.- Specified by:
createTopicin interfacejavax.jms.Session
- Since:
- 1.1
createDurableSubscriber
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name) throws javax.jms.JMSException
- 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 uses a durable
TopicSubscriber. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.Sessions with durable subscribers must always provide the same client identifier. In addition, each client must specify a name that uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have a
TopicSubscriberfor a particular durable subscription.A client can change an existing durable subscription by creating a durable
TopicSubscriberwith 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.In some cases, a connection may both publish and subscribe to a topic. The subscriber
NoLocalattribute allows a subscriber to inhibit the delivery of messages published by its own connection. The default value for this attribute is false.- Specified by:
createDurableSubscriberin interfacejavax.jms.Session
- Since:
- 1.1
createDurableSubscriber
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal) throws javax.jms.JMSException
- 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 uses a durable
TopicSubscriber. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.Sessions with durable subscribers must always provide the same client identifier. In addition, each client must specify a name which uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have a
TopicSubscriberfor a particular durable subscription. An inactive durable subscriber is one that exists but does not currently have a message consumer associated with it.A client can change an existing durable subscription by creating a durable
TopicSubscriberwith 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 interfacejavax.jms.Session
- Since:
- 1.1
createBrowser
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue) throws javax.jms.JMSException
- Creates a
QueueBrowserobject to peek at the messages on the specified queue.- Specified by:
createBrowserin interfacejavax.jms.Session
- Since:
- 1.1
createBrowser
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, java.lang.String messageSelector) throws javax.jms.JMSException
- Creates a
QueueBrowserobject to peek at the messages on the specified queue using a message selector.- Specified by:
createBrowserin interfacejavax.jms.Session
- Since:
- 1.1
createTemporaryQueue
public javax.jms.TemporaryQueue createTemporaryQueue() throws javax.jms.JMSException
- Creates a
TemporaryQueueobject. Its lifetime will be that of theConnectionunless it is deleted earlier.- Specified by:
createTemporaryQueuein interfacejavax.jms.Session
- Since:
- 1.1
createTemporaryTopic
public javax.jms.TemporaryTopic createTemporaryTopic() throws javax.jms.JMSException
- Creates a
TemporaryTopicobject. Its lifetime will be that of theConnectionunless it is deleted earlier.- Specified by:
createTemporaryTopicin interfacejavax.jms.Session
- Since:
- 1.1
createReceiver
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue) throws javax.jms.JMSException
- Creates a
QueueReceiverobject to receive messages from the specified queue.- Specified by:
createReceiverin interfacejavax.jms.QueueSession
createReceiver
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue, java.lang.String messageSelector) throws javax.jms.JMSException
- Creates a
QueueReceiverobject to receive messages from the specified queue using a message selector.- Specified by:
createReceiverin interfacejavax.jms.QueueSession
createSender
public javax.jms.QueueSender createSender(javax.jms.Queue queue) throws javax.jms.JMSException
- Creates a
QueueSenderobject to send messages to the specified queue.- Specified by:
createSenderin interfacejavax.jms.QueueSession
createSubscriber
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic) throws javax.jms.JMSException
- Creates a nondurable subscriber to the specified topic.
A client uses a
TopicSubscriberobject to receive messages that have been published to a topic.Regular
TopicSubscriberobjects are not durable. They receive only messages that are published while they are active.In some cases, a connection may both publish and subscribe to a topic. The subscriber
NoLocalattribute allows a subscriber to inhibit the delivery of messages published by its own connection. The default value for this attribute is false.- Specified by:
createSubscriberin interfacejavax.jms.TopicSession
createSubscriber
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, java.lang.String messageSelector, boolean noLocal) throws javax.jms.JMSException
- Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages
published by its own connection should be delivered to it.
A client uses a
TopicSubscriberobject to receive messages that have been published to a topic.Regular
TopicSubscriberobjects are not durable. They receive only messages that are published while they are active.Messages filtered out by a subscriber's message selector will never be delivered to the subscriber. From the subscriber's perspective, they do not exist.
In some cases, a connection may both publish and subscribe to a topic. The subscriber
NoLocalattribute allows a subscriber to inhibit the delivery of messages published by its own connection. The default value for this attribute is false.- Specified by:
createSubscriberin interfacejavax.jms.TopicSession
createPublisher
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws javax.jms.JMSException
- Creates a publisher for the specified topic.
A client uses a
TopicPublisherobject to publish messages on a topic. Each time a client creates aTopicPublisheron a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent.- Specified by:
createPublisherin interfacejavax.jms.TopicSession
unsubscribe
public void unsubscribe(java.lang.String name) throws javax.jms.JMSException
- Unsubscribes a durable subscription that has been created by a client.
This method deletes the state being maintained on behalf of the subscriber by its provider.
It is erroneous for a client to delete a durable subscription while there is an active
MessageConsumerorTopicSubscriberfor the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.- Specified by:
unsubscribein interfacejavax.jms.Session
- Since:
- 1.1
isTarget
public boolean isTarget(org.activemq.message.ActiveMQMessage message)
- Tests to see if the Message Dispatcher is a target for this message
- Specified by:
isTargetin interfaceActiveMQMessageDispatcher
dispatch
public void dispatch(org.activemq.message.ActiveMQMessage message)
- Dispatch an ActiveMQMessage
- Specified by:
dispatchin interfaceActiveMQMessageDispatcher
acknowledge
public void acknowledge(org.activemq.message.ActiveMQMessage caller) throws javax.jms.JMSException
- Acknowledges all consumed messages of the session of this consumed message.
All consumed JMS messages support the
acknowledgemethod for use when a client has specified that its JMS session's consumed messages are to be explicitly acknowledged. By invokingacknowledgeon a consumed message, a client acknowledges all messages consumed by the session that the message was delivered to.Calls to
acknowledgeare ignored for both transacted sessions and sessions specified to use implicit acknowledgement modes.A client may individually acknowledge each message as it is consumed, or it may choose to acknowledge messages as an application-defined group (which is done by calling acknowledge on the last received message of the group, thereby acknowledging all messages consumed by the session.)
Messages that have been received but not acknowledged may be redelivered.
- Specified by:
acknowledgein interfaceorg.activemq.message.MessageAcknowledge
doAcknowledge
protected void doAcknowledge(boolean isClosing)
throws javax.jms.JMSException
beforeMessageDelivered
protected void beforeMessageDelivered(org.activemq.message.ActiveMQMessage message)
afterMessageDelivered
protected void afterMessageDelivered(boolean sendAcknowledge,
org.activemq.message.ActiveMQMessage message,
boolean messageConsumed,
boolean messageExpired,
boolean beforeCalled)
removeTemporaryDestination
public void removeTemporaryDestination(org.activemq.message.ActiveMQDestination destination) throws javax.jms.JMSException
- remove a temporary destination
sendMessageAck
private void sendMessageAck(org.activemq.message.ActiveMQMessage message, boolean messageConsumed, boolean messageExpired) throws javax.jms.JMSException
doSendMessageAck
private void doSendMessageAck(org.activemq.message.ActiveMQMessage message, boolean messageConsumed, boolean messageExpired) throws javax.jms.JMSException
addConsumer
protected void addConsumer(ActiveMQMessageConsumer consumer) throws javax.jms.JMSException
removeConsumer
protected void removeConsumer(ActiveMQMessageConsumer consumer) throws javax.jms.JMSException
createConsumerInfo
protected org.activemq.message.ConsumerInfo createConsumerInfo(ActiveMQMessageConsumer consumer) throws javax.jms.JMSException
addProducer
protected void addProducer(ActiveMQMessageProducer producer) throws javax.jms.JMSException
removeProducer
protected void removeProducer(ActiveMQMessageProducer producer) throws javax.jms.JMSException
createProducerInfo
protected org.activemq.message.ProducerInfo createProducerInfo(ActiveMQMessageProducer producer) throws javax.jms.JMSException
start
protected void start()
throws javax.jms.JMSException
- Start this Session
stop
protected void stop()
- Stop this Session
getSessionId
protected short getSessionId()
setSessionId
protected void setSessionId(short sessionId)
getStartTime
protected long getStartTime()
setStartTime
protected void setStartTime(long startTime)
send
protected void send(ActiveMQMessageProducer producer, javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive, boolean reuseMessageId) throws javax.jms.JMSException
- send the message for dispatch by the broker
doStartTransaction
protected void doStartTransaction()
throws javax.jms.JMSException
- Send TransactionInfo to indicate transaction has started
setSessionConsumerDispatchState
protected void setSessionConsumerDispatchState(int value)
throws javax.jms.JMSException
redeliverUnacknowledgedMessages
protected void redeliverUnacknowledgedMessages()
redeliverUnacknowledgedMessages
protected void redeliverUnacknowledgedMessages(boolean onlyDeliverTransientConsumed)
clearMessagesInProgress
protected void clearMessagesInProgress()
hasUncomsumedMessages
public boolean hasUncomsumedMessages()
getUnconsumedMessages
public java.util.List getUnconsumedMessages()
isTransacted
public boolean isTransacted()
isClientAcknowledge
protected boolean isClientAcknowledge()
isInternalSession
public boolean isInternalSession()
setInternalSession
public void setInternalSession(boolean internalSession)
getDeliveryListener
public ActiveMQSession.DeliveryListener getDeliveryListener()
setDeliveryListener
public void setDeliveryListener(ActiveMQSession.DeliveryListener deliveryListener)
|
|||||||||
| Home >> All >> org >> [ activemq overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.activemq.ActiveMQSession