JMSContext is the main interface in the simplified JMS API
introduced for JMS 2.0. This combines in a single object the functionality of
two separate objects from the JMS 1.1 API: a Connection and a
Session.
When an application needs to send messages it use the
createProducer method to create a JMSProducer which
provides methods to configure and send messages. Messages may be sent either
synchronously or asynchronously.
When an application needs to receive messages it uses one of several
createConsumer or createDurableConsumer methods to
create a JMSConsumer . A JMSConsumer provides
methods to receive messages either synchronously or asynchronously.
In terms of the JMS 1.1 API a JMSContext should be thought of as
representing both a Connection and a Session.
Although the simplified API removes the need for applications to use those
objects, the concepts of connection and session remain important. A
connection represents a physical link to the JMS server and a session
represents a single-threaded context for sending and receiving messages.
A JMSContext may be created by calling one of several
createContext methods on a ConnectionFactory. A
JMSContext that is created in this way is described as being
application-managed. An application-managed JMSContext
must be closed when no longer needed by calling its close
method.
Applications running in the Java EE web and EJB containers may alternatively
inject a JMSContext into their application using the
@Inject annotation. A JMSContext that is created in
this way is described as being container-managed. A
container-managed JMSContext will be closed automatically by
the container.
Applications running in the Java EE web and EJB containers are not permitted to create more than one active session on a connection so combining them in a single object takes advantage of this restriction to offer a simpler API.
However applications running in a Java SE environment or in the Java EE
application client container are permitted to create multiple active sessions
on the same connection. This allows the same physical connection to be used
in multiple threads simultaneously. Such applications which require multiple
sessions to be created on the same connection should use one of the
createContext methods on the ConnectionFactory to
create the first JMSContext and then use the
createContext method on JMSContext to create
additional JMSContext objects that use the same connection. All
these JMSContext objects are application-managed and must be
closed when no longer needed by calling their close method.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | AUTO_ACKNOWLEDGE
With this session mode, the JMSContext's session automatically
acknowledges a client's receipt of a message either when the session has
successfully returned from a call to |
| public static final int | CLIENT_ACKNOWLEDGE
With this session mode, the client acknowledges a consumed message by
calling the message's |
| public static final int | DUPS_OK_ACKNOWLEDGE
This session mode instructs the JMSContext's session to lazily acknowledge the delivery of messages. |
| public static final int | SESSION_TRANSACTED
This session mode instructs the JMSContext's session to deliver and
consume messages in a local transaction which will be subsequently
committed by calling |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | close()
Redeclares java. This closes the underlying session and any underlying producers and consumers. |
| public void | |
| public QueueBrowser | createBrowser(Queue
the queue)queue to accessCreates a |
| public QueueBrowser | createBrowser(Queue
the queue, String queue to accessonly messages with properties matching the message selector
expression are delivered. A value of null or an empty string
indicates that there is no message selector for the message
consumer. messageSelector)Creates a |
| public BytesMessage | |
| public JMSConsumer | createConsumer(Destination
the destination)Destination to access.Creates a |
| public JMSConsumer | createConsumer(Destination
the destination, String Destination to accessonly messages with properties matching the message selector
expression are delivered. A value of null or an empty string
indicates that there is no message selector for the
messageSelector)JMSConsumer.Creates a |
| public JMSConsumer | createConsumer(Destination
the destination, String Destination to accessonly messages with properties matching the message selector
expression are delivered. A value of null or an empty string
indicates that there is no message selector for the
messageSelector, boolean JMSConsumer.if true, and the destination is a topic, then the
noLocal)JMSConsumer will not receive messages published
to the topic by its own connectionCreates a |
| public JMSContext | Returns: a newly created JMSContextindicates which of four possible session modes will be used.
The permitted values are
sessionMode)JMSContext.SESSION_TRANSACTED,
JMSContext.CLIENT_ACKNOWLEDGE,
JMSContext.AUTO_ACKNOWLEDGE and
JMSContext.DUPS_OK_ACKNOWLEDGE.Creates a new |
| public JMSConsumer | createDurableConsumer(Topic
the non-temporary topic, String Topic to subscribe tothe name used to identify this subscription name)Creates an unshared durable subscription on the specified topic (if one does not already exist) and creates a consumer on that durable subscription. |
| public JMSConsumer | createDurableConsumer(Topic
the non-temporary topic, String Topic to subscribe tothe name used to identify this subscription name, String only messages with properties matching the message selector
expression are added to the durable subscription. A value of
null or an empty string indicates that there is no message
selector for the durable subscription. messageSelector, boolean if true then any messages published to the topic using this
session's connection, or any other connection with the same
client identifier, will not be added to the durable
subscription. noLocal)Creates an unshared durable subscription on the specified topic (if one
does not already exist), specifying a message selector and the
|
| public MapMessage | |
| public Message | |
| public ObjectMessage | |
| public ObjectMessage | createObjectMessage(Serializable
the object to use to initialize this message object)Creates an initialized |
| public JMSProducer | Returns: A newJMSProducer objectCreates a new |
| public Queue | Returns: a Queue object which encapsulates the specified nameA provider-specific queue name queueName)Creates a |
| public JMSConsumer | createSharedConsumer(Topic
the topic, String Topic to subscribe tothe name used to identify the shared non-durable subscription sharedSubscriptionName)Creates a shared non-durable subscription with the specified name on the specified topic (if one does not already exist) and creates a consumer on that subscription. |
| public JMSConsumer | createSharedConsumer(Topic
the topic, String Topic to subscribe tothe name used to identify the shared non-durable subscription sharedSubscriptionName, String only messages with properties matching the message selector
expression are added to the shared non-durable subscription. A
value of null or an empty string indicates that there is no
message selector for the shared non-durable subscription. messageSelector)Creates a shared non-durable subscription with the specified name on the specified topic (if one does not already exist) specifying a message selector, and creates a consumer on that subscription. |
| public JMSConsumer | createSharedDurableConsumer(Topic
the non-temporary topic, String Topic to subscribe tothe name used to identify this subscription name)Creates a shared durable subscription on the specified topic (if one does not already exist), specifying a message selector, and creates a consumer on that durable subscription. |
| public JMSConsumer | createSharedDurableConsumer(Topic
the non-temporary topic, String Topic to subscribe tothe name used to identify this subscription name, String only messages with properties matching the message selector
expression are added to the durable subscription. A value of
null or an empty string indicates that there is no message
selector for the durable subscription. messageSelector)Creates a shared durable subscription on the specified topic (if one does not already exist), specifying a message selector, and creates a consumer on that durable subscription. |
| public StreamMessage | |
| public TemporaryQueue | |
| public TemporaryTopic | |
| public TextMessage | |
| public TextMessage | createTextMessage(String
the string used to initialize this message text)Creates an initialized |
| public Topic | Returns: a Topic object which encapsulates the specified nameA provider-specific topic name topicName)Creates a |
| public boolean | Returns: whether the underlying connection used by thisJMSContext will be started automatically when a
consumer is created.Returns whether the underlying connection used by this
|
| public String | Returns: the unique client identifierGets the client identifier for the JMSContext's connection. |
| public ExceptionListener | Returns: theExceptionListener for the JMSContext's
connection, or null if no ExceptionListener is
associated with that connection.Gets the |
| public ConnectionMetaData | Returns: the connection metadataGets the connection metadata for the JMSContext's connection. |
| public int | Returns: the session mode of the JMSContext's sessionReturns the session mode of the JMSContext's session. |
| public boolean | Returns: true if the session is in transacted modeIndicates whether the JMSContext's session is in transacted mode. |
| public void | recover()
Stops message delivery in the JMSContext's session, and restarts message delivery with the oldest unacknowledged message. |
| public void | |
| public void | setAutoStart(boolean
Whether the underlying connection used by this
autoStart)JMSContext will be automatically started when a
consumer is created.Specifies whether the underlying connection used by this
|
| public void | setClientID(String
the unique client identifier clientID)Sets the client identifier for the JMSContext's connection. |
| public void | setExceptionListener(ExceptionListener
the exception listener listener)Sets an exception listener for the JMSContext's connection. |
| public void | |
| public void | |
| public void | unsubscribe(String
the name used to identify this subscription name)Unsubscribes a durable subscription that has been created by a client. |
| AUTO_ACKNOWLEDGE | back to summary |
|---|---|
| public static final int AUTO_ACKNOWLEDGE With this session mode, the JMSContext's session automatically
acknowledges a client's receipt of a message either when the session has
successfully returned from a call to | |
| CLIENT_ACKNOWLEDGE | back to summary |
|---|---|
| public static final int CLIENT_ACKNOWLEDGE With this session mode, the client acknowledges a consumed message by
calling the message's When this session mode is used, a client may build up a large number of unacknowledged messages while attempting to process them. A JMS provider should provide administrators with a way to limit client overrun so that clients are not driven to resource exhaustion and ensuing failure when some resource they are using is temporarily blocked.
| |
| DUPS_OK_ACKNOWLEDGE | back to summary |
|---|---|
| public static final int DUPS_OK_ACKNOWLEDGE This session mode instructs the JMSContext's session to lazily acknowledge the delivery of messages. This is likely to result in the delivery of some duplicate messages if the JMS provider fails, so it should only be used by consumers that can tolerate duplicate messages. Use of this mode can reduce session overhead by minimizing the work the session does to prevent duplicates. | |
| SESSION_TRANSACTED | back to summary |
|---|---|
| public static final int SESSION_TRANSACTED This session mode instructs the JMSContext's session to deliver and
consume messages in a local transaction which will be subsequently
committed by calling | |
| acknowledge | back to summary |
|---|---|
| public void acknowledge() Acknowledges all messages consumed by the JMSContext's session. This method is for use when the session has an acknowledgement mode of CLIENT_ACKNOWLEDGE. If the session is transacted or has an acknowledgement mode of AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE calling this method has no effect.
This method has identical behaviour to the Messages that have been received but not acknowledged may be redelivered.
This method must not be used if the
| |
| close | back to summary |
|---|---|
| public void close() Redeclares java. Closes the JMSContext This closes the underlying session and any underlying producers and consumers. If there are no other active (not closed) JMSContext objects using the underlying connection then this method also closes the underlying connection. Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough. Closing a connection causes all temporary destinations to be deleted.
When this method is invoked, it should not return until message
processing has been shut down in an orderly fashion. This means that all
message listeners that may have been running have returned, and that all
pending receives have returned. A close terminates all pending message
receives on the connection's sessions' consumers. The receives may return
with a message or with null, depending on whether there was a message
available at the time of the close. If one or more of the connection's
sessions' message listeners is processing a message at the time when
connection
However if the close method is called from a message listener on its own
Since two alternative behaviors are permitted in this case, applications
should avoid calling close from a message listener on its own
This method must not return until any incomplete asynchronous send operations for this JMSContext have been completed and any CompletionListener callbacks have returned. Incomplete sends should be allowed to complete normally unless an error occurs.
For the avoidance of doubt, if an exception listener for the JMSContext's
connection is running when
Closing a connection causes any of its sessions' transactions in progress
to be rolled back. In the case where a session's work is coordinated by
an external transaction manager, a session's Closing a connection does NOT force an acknowledgment of client-acknowledged sessions.
Invoking the A CompletionListener callback method must not call close on its own JMSContext. Doing so will cause an IllegalStateRuntimeException to be thrown.
This method must not be used if the
| |
| commit | back to summary |
|---|---|
| public void commit() Commits all messages done in this transaction and releases any locks currently held. This method must not return until any incomplete asynchronous send operations for this JMSContext have been completed and any CompletionListener callbacks have returned. Incomplete sends should be allowed to complete normally unless an error occurs. A CompletionListener callback method must not call commit on its own JMSContext. Doing so will cause an IllegalStateRuntimeException to be thrown.
This method must not be used if the
| |
| createBrowser | back to summary |
|---|---|
| public QueueBrowser createBrowser(Queue queue) Creates a
| |
| createBrowser | back to summary |
|---|---|
| public QueueBrowser createBrowser(Queue queue, String messageSelector) Creates a
| |
| createBytesMessage | back to summary |
|---|---|
| public BytesMessage createBytesMessage() Creates a
| |
| createConsumer | back to summary |
|---|---|
| public JMSConsumer createConsumer(Destination destination) Creates a
A client uses a
| |
| createConsumer | back to summary |
|---|---|
| public JMSConsumer createConsumer(Destination destination, String messageSelector) Creates a
A client uses a
| |
| createConsumer | back to summary |
|---|---|
| public JMSConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) Creates a
A client uses a
The
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(int sessionMode) Creates a new
This method does not start the connection. If the connection has not
already been started then it will be automatically started when a
This method must not be used by applications running in the Java EE web
or EJB containers because doing so would violate the restriction that
such an application must not attempt to create more than one active (not
closed)
| |
| createDurableConsumer | back to summary |
|---|---|
| public JMSConsumer createDurableConsumer(Topic topic, String name) Creates an unshared durable subscription on the specified topic (if one
does not already exist) and creates a consumer on that durable
subscription. This method creates the durable subscription without a
message selector and with a A durable subscription is used by an application which needs to receive all the messages published on a topic, including the ones published when there is no active consumer associated with it. The JMS provider retains a record of this durable subscription and ensures that all messages from the topic's publishers are retained until they are delivered to, and acknowledged by, a consumer on this durable subscription or until they have expired.
A durable subscription will continue to accumulate messages until it is
deleted using the
This method may only be used with unshared durable subscriptions. Any
durable subscription created using this method will be unshared. This
means that only one active (i.e. not closed) consumer on the subscription
may exist at a time. The term "consumer" here means a
An unshared durable subscription is identified by a name specified by the client and by the client identifier, which must be set. An application which subsequently wishes to create a consumer on that unshared durable subscription must use the same client identifier.
If an unshared durable subscription already exists with the same name and
client identifier, and the same topic, message selector and
If an unshared durable subscription already exists with the same name and
client identifier, and there is a consumer already active (i.e. not
closed) on the durable subscription, then a
If an unshared durable subscription already exists with the same name and
client identifier but a different topic, message selector or
A shared durable subscription and an unshared durable subscription may
not have the same name and client identifier. If a shared durable
subscription already exists with the same name and client identifier then
a There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId. Such subscriptions would be completely separate.
| |
| createDurableConsumer | back to summary |
|---|---|
| public JMSConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal) Creates an unshared durable subscription on the specified topic (if one
does not already exist), specifying a message selector and the
A durable subscription is used by an application which needs to receive all the messages published on a topic, including the ones published when there is no active consumer associated with it. The JMS provider retains a record of this durable subscription and ensures that all messages from the topic's publishers are retained until they are delivered to, and acknowledged by, a consumer on this durable subscription or until they have expired.
A durable subscription will continue to accumulate messages until it is
deleted using the
This method may only be used with unshared durable subscriptions. Any
durable subscription created using this method will be unshared. This
means that only one active (i.e. not closed) consumer on the subscription
may exist at a time. The term "consumer" here means a
An unshared durable subscription is identified by a name specified by the client and by the client identifier, which must be set. An application which subsequently wishes to create a consumer on that unshared durable subscription must use the same client identifier.
If an unshared durable subscription already exists with the same name and
client identifier, and the same topic, message selector and
If an unshared durable subscription already exists with the same name and
client identifier, and there is a consumer already active (i.e. not
closed) on the durable subscription, then a
If an unshared durable subscription already exists with the same name and
client identifier but a different topic, message selector or
If
A shared durable subscription and an unshared durable subscription may
not have the same name and client identifier. If a shared durable
subscription already exists with the same name and client identifier then
a There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId. Such subscriptions would be completely separate.
This method is identical to the corresponding
| |
| createMapMessage | back to summary |
|---|---|
| public MapMessage createMapMessage() Creates a
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createMessage | back to summary |
|---|---|
| public Message createMessage() Creates a
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createObjectMessage | back to summary |
|---|---|
| public ObjectMessage createObjectMessage() Creates an
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createObjectMessage | back to summary |
|---|---|
| public ObjectMessage createObjectMessage(Serializable object) Creates an initialized
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createProducer | back to summary |
|---|---|
| public JMSProducer createProducer() Creates a new
| |
| createQueue | back to summary |
|---|---|
| public Queue createQueue(String queueName) Creates a
The use of provider-specific queue names in an application may render the
application non-portable. Portable applications are recommended to not
use this method but instead look up an administratively-defined
Note that this method simply creates an object that encapsulates the name
of a queue. It does not create the physical queue in the JMS provider.
JMS does not provide a method to create the physical queue, since this
would be specific to a given JMS provider. Creating a physical queue is
provider-specific and is typically an administrative task performed by an
administrator, though some providers may create them automatically when
needed. The one exception to this is the creation of a temporary queue,
which is done using the
| |
| createSharedConsumer | back to summary |
|---|---|
| public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) Creates a shared non-durable subscription with the specified name on the specified topic (if one does not already exist) and creates a consumer on that subscription. This method creates the non-durable subscription without a message selector.
If a shared non-durable subscription already exists with the same name
and client identifier (if set), and the same topic and message selector
has been specified, then this method creates a
A non-durable shared subscription is used by a client which needs to be
able to share the work of receiving messages from a topic subscription
amongst multiple consumers. A non-durable shared subscription may
therefore have more than one consumer. Each message from the subscription
will be delivered to only one of the consumers on that subscription. Such
a subscription is not persisted and will be deleted (together with any
undelivered messages associated with it) when there are no consumers on
it. The term "consumer" here means a A shared non-durable subscription is identified by a name specified by the client and by the client identifier (which may be unset). An application which subsequently wishes to create a consumer on that shared non-durable subscription must use the same client identifier.
If a shared non-durable subscription already exists with the same name
and client identifier (if set) but a different topic or message selector
value has been specified, and there is a consumer already
active (i.e. not closed) on the subscription, then a There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId (which may be unset). Such subscriptions would be completely separate.
| |
| createSharedConsumer | back to summary |
|---|---|
| public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) Creates a shared non-durable subscription with the specified name on the specified topic (if one does not already exist) specifying a message selector, and creates a consumer on that subscription.
If a shared non-durable subscription already exists with the same name
and client identifier (if set), and the same topic and message selector
has been specified, then this method creates a
A non-durable shared subscription is used by a client which needs to be
able to share the work of receiving messages from a topic subscription
amongst multiple consumers. A non-durable shared subscription may
therefore have more than one consumer. Each message from the subscription
will be delivered to only one of the consumers on that subscription. Such
a subscription is not persisted and will be deleted (together with any
undelivered messages associated with it) when there are no consumers on
it. The term "consumer" here means a A shared non-durable subscription is identified by a name specified by the client and by the client identifier (which may be unset). An application which subsequently wishes to create a consumer on that shared non-durable subscription must use the same client identifier.
If a shared non-durable subscription already exists with the same name
and client identifier (if set) but a different topic or message selector
has been specified, and there is a consumer already
active (i.e. not closed) on the subscription, then a There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId (which may be unset). Such subscriptions would be completely separate.
| |
| createSharedDurableConsumer | back to summary |
|---|---|
| public JMSConsumer createSharedDurableConsumer(Topic topic, String name) Creates a shared durable subscription on the specified topic (if one does not already exist), specifying a message selector, and creates a consumer on that durable subscription. This method creates the durable subscription without a message selector. A durable subscription is used by an application which needs to receive all the messages published on a topic, including the ones published when there is no active consumer associated with it. The JMS provider retains a record of this durable subscription and ensures that all messages from the topic's publishers are retained until they are delivered to, and acknowledged by, a consumer on this durable subscription or until they have expired.
A durable subscription will continue to accumulate messages until it is
deleted using the
This method may only be used with shared durable subscriptions. Any
durable subscription created using this method will be shared. This means
that multiple active (i.e. not closed) consumers on the subscription may
exist at the same time. The term "consumer" here means a
A shared durable subscription is identified by a name specified by the client and by the client identifier (which may be unset). An application which subsequently wishes to create a consumer on that shared durable subscription must use the same client identifier.
If a shared durable subscription already exists with the same name and
client identifier (if set), and the same topic and message selector
has been specified, then this method creates a
If a shared durable subscription already exists with the same name and client identifier (if set) but a different topic or message selector has been specified, and there is no consumer already active (i.e. not closed) on the durable subscription then this is equivalent to unsubscribing (deleting) the old one and creating a new one.
If a shared durable subscription already exists with the same name and
client identifier (if set) but a different topic or message selector
has been specified, and there is a consumer already
active (i.e. not closed) on the durable subscription, then a
A shared durable subscription and an unshared durable subscription may
not have the same name and client identifier (if set). If an unshared
durable subscription already exists with the same name and client
identifier (if set) then a If a message selector is specified then only messages with properties matching the message selector expression will be added to the subscription. There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId (which may be unset). Such subscriptions would be completely separate.
| |
| createSharedDurableConsumer | back to summary |
|---|---|
| public JMSConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector) Creates a shared durable subscription on the specified topic (if one does not already exist), specifying a message selector, and creates a consumer on that durable subscription. A durable subscription is used by an application which needs to receive all the messages published on a topic, including the ones published when there is no active consumer associated with it. The JMS provider retains a record of this durable subscription and ensures that all messages from the topic's publishers are retained until they are delivered to, and acknowledged by, a consumer on this durable subscription or until they have expired.
A durable subscription will continue to accumulate messages until it is
deleted using the
This method may only be used with shared durable subscriptions. Any
durable subscription created using this method will be shared. This means
that multiple active (i.e. not closed) consumers on the subscription may
exist at the same time. The term "consumer" here means a
A shared durable subscription is identified by a name specified by the client and by the client identifier (which may be unset). An application which subsequently wishes to create a consumer on that shared durable subscription must use the same client identifier.
If a shared durable subscription already exists with the same name and
client identifier (if set), and the same topic and message selector have
been specified, then this method creates a
If a shared durable subscription already exists with the same name and client identifier (if set), but a different topic or message selector has been specified, and there is no consumer already active (i.e. not closed) on the durable subscription then this is equivalent to unsubscribing (deleting) the old one and creating a new one.
If a shared durable subscription already exists with the same name and
client identifier (if set) but a different topic or message selector
has been specified, and there is a consumer already
active (i.e. not closed) on the durable subscription, then a
A shared durable subscription and an unshared durable subscription may
not have the same name and client identifier (if set). If an unshared
durable subscription already exists with the same name and client
identifier (if set) then a There is no restriction on durable subscriptions and shared non-durable subscriptions having the same name and clientId (which may be unset). Such subscriptions would be completely separate.
| |
| createStreamMessage | back to summary |
|---|---|
| public StreamMessage createStreamMessage() Creates a
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createTemporaryQueue | back to summary |
|---|---|
| public TemporaryQueue createTemporaryQueue() Creates a
| |
| createTemporaryTopic | back to summary |
|---|---|
| public TemporaryTopic createTemporaryTopic() Creates a
| |
| createTextMessage | back to summary |
|---|---|
| public TextMessage createTextMessage() Creates a
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createTextMessage | back to summary |
|---|---|
| public TextMessage createTextMessage(String text) Creates an initialized
The message object returned may be sent using any The message object returned may be optimised for use with the JMS provider used to create it. However it can be sent using any JMS provider, not just the JMS provider used to create it.
| |
| createTopic | back to summary |
|---|---|
| public Topic createTopic(String topicName) Creates a
The use of provider-specific topic names in an application may render the
application non-portable. Portable applications are recommended to not
use this method but instead look up an administratively-defined
Note that this method simply creates an object that encapsulates the name
of a topic. It does not create the physical topic in the JMS provider.
JMS does not provide a method to create the physical topic, since this
would be specific to a given JMS provider. Creating a physical topic is
provider-specific and is typically an administrative task performed by an
administrator, though some providers may create them automatically when
needed. The one exception to this is the creation of a temporary topic,
which is done using the
| |
| getAutoStart | back to summary |
|---|---|
| public boolean getAutoStart() Returns whether the underlying connection used by this
| |
| getClientID | back to summary |
|---|---|
| public String getClientID() Gets the client identifier for the JMSContext's connection.
This value is specific to the JMS provider. It is either preconfigured by
an administrator in a
| |
| getExceptionListener | back to summary |
|---|---|
| public ExceptionListener getExceptionListener() Gets the
| |
| getMetaData | back to summary |
|---|---|
| public ConnectionMetaData getMetaData() Gets the connection metadata for the JMSContext's connection.
| |
| getSessionMode | back to summary |
|---|---|
| public int getSessionMode() Returns the session mode of the JMSContext's session. This can be set at the time that the JMSContext is created. Possible values are JMSContext.SESSION_TRANSACTED, JMSContext.AUTO_ACKNOWLEDGE, JMSContext.CLIENT_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE If a session mode was not specified when the JMSContext was created a value of JMSContext.AUTO_ACKNOWLEDGE will be returned.
| |
| getTransacted | back to summary |
|---|---|
| public boolean getTransacted() Indicates whether the JMSContext's session is in transacted mode.
| |
| recover | back to summary |
|---|---|
| public void recover() Stops message delivery in the JMSContext's 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:
This method must not be used if the
| |
| rollback | back to summary |
|---|---|
| public void rollback() Rolls back any messages done in this transaction and releases any locks currently held. This method must not return until any incomplete asynchronous send operations for this JMSContext have been completed and any CompletionListener callbacks have returned. Incomplete sends should be allowed to complete normally unless an error occurs. A CompletionListener callback method must not call rollback on its own JMSContext. Doing so will cause an IllegalStateRuntimeException to be thrown.
This method must not be used if the
| |
| setAutoStart | back to summary |
|---|---|
| public void setAutoStart(boolean autoStart) Specifies whether the underlying connection used by this
This method does not itself either start or stop the connection.
This method must not be used if the
| |
| setClientID | back to summary |
|---|---|
| public void setClientID(String clientID) Sets the client identifier for the JMSContext's connection.
The preferred way to assign a JMS client's client identifier is for it to
be configured in a client-specific
Alternatively, a client can set the client identifier for the
JMSContext's connection using a provider-specific value. The facility
to set its client identifier explicitly is not a mechanism for overriding
the identifier that has been administratively configured. It is provided
for the case where no administratively specified identifier exists. If
one does exist, an attempt to change it by setting it must throw an
The purpose of the client identifier is to associate the JMSContext's connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.
If another connection with the same
This method must not be used in a Java EE web or EJB application. Doing
so may cause a
This method must not be used if the
| |
| setExceptionListener | back to summary |
|---|---|
| public void setExceptionListener(ExceptionListener listener) Sets an exception listener for the JMSContext's connection.
If a JMS provider detects a serious problem with a connection, it informs
the connection's An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.
A connection serializes execution of its A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.
This method must not be used in a Java EE web or EJB application. Doing
so may cause a
This method must not be used if the
| |
| start | back to summary |
|---|---|
| public void start() Starts (or restarts) delivery of incoming messages by the JMSContext's
connection. A call to
This method must not be used if the
| |
| stop | back to summary |
|---|---|
| public void stop() Temporarily stops the delivery of incoming messages by the JMSContext's
connection. Delivery can be restarted using the
Stopping a connection has no effect on its ability to send messages. A
call to
A call to
If message listeners are running when
However if the stop method is called from a message listener on its own
Since two alternative behaviors are permitted in this case, applications
should avoid calling
For the avoidance of doubt, if an exception listener for the JMSContext's
connection is running when
This method must not be used in a Java EE web or EJB application. Doing
so may cause a
This method must not be used if the
| |
| unsubscribe | back to summary |
|---|---|
| public void unsubscribe(String name) 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. A durable subscription is identified by a name specified by the client and by the client identifier if set. If the client identifier was set when the durable subscription was created then a client which subsequently wishes to use this method to delete a durable subscription must use the same client identifier. It is erroneous for a client to delete a durable subscription while there is an active (not closed) consumer on that subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.
If the active consumer is represented by a
If the active consumer was created by calling
If the active consumer is represented by a
| |