-
- All Superinterfaces:
- AutoCloseable, Runnable, Session
public interface QueueSession extends Session
AQueueSession
object provides methods for creatingQueueReceiver
,QueueSender
,QueueBrowser
, andTemporaryQueue
objects.If there are messages that have been received but not acknowledged when a
QueueSession
terminates, these messages will be retained and redelivered when a consumer next accesses the queue.A
QueueSession
is used for creating Point-to-Point specific objects. In general, use theSession
object. TheQueueSession
is used to support existing code. Using theSession
object simplifies the programming model, and allows transactions to be used across the two messaging domains.A
QueueSession
cannot be used to create objects specific to the publish/subscribe domain. The following methods inherit fromSession
, but must throw anIllegalStateException
if they are used fromQueueSession
:createDurableSubscriber
createDurableConsumer
createSharedConsumer
createSharedDurableConsumer
createTemporaryTopic
createTopic
unsubscribe
- Since:
- JMS 1.0
- Version:
- JMS 2.0
- See Also:
Session
,QueueConnection.createQueueSession(boolean, int)
,XAQueueSession.getQueueSession()
-
-
Field Summary
-
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description QueueBrowser
createBrowser(Queue queue)
Creates aQueueBrowser
object to peek at the messages on the specified queue.QueueBrowser
createBrowser(Queue queue, String messageSelector)
Creates aQueueBrowser
object to peek at the messages on the specified queue using a message selector.Queue
createQueue(String queueName)
Creates a queue identity given aQueue
name.QueueReceiver
createReceiver(Queue queue)
Creates aQueueReceiver
object to receive messages from the specified queue.QueueReceiver
createReceiver(Queue queue, String messageSelector)
Creates aQueueReceiver
object to receive messages from the specified queue using a message selector.QueueSender
createSender(Queue queue)
Creates aQueueSender
object to send messages to the specified queue.TemporaryQueue
createTemporaryQueue()
Creates aTemporaryQueue
object.-
Methods inherited from interface javax.jms.Session
close, commit, createBytesMessage, createConsumer, createConsumer, createConsumer, createDurableConsumer, createDurableConsumer, createDurableSubscriber, createDurableSubscriber, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createSharedConsumer, createSharedConsumer, createSharedDurableConsumer, createSharedDurableConsumer, createStreamMessage, createTemporaryTopic, createTextMessage, createTextMessage, createTopic, getAcknowledgeMode, getMessageListener, getTransacted, recover, rollback, run, setMessageListener, unsubscribe
-
-
-
-
Method Detail
-
createQueue
Queue createQueue(String queueName) throws JMSException
Creates a queue identity given aQueue
name.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
createTemporaryQueue
method.- Specified by:
createQueue
in interfaceSession
- Parameters:
queueName
- the name of thisQueue
- Returns:
- a
Queue
with the given name - Throws:
JMSException
- if the session fails to create a queue due to some internal error.
-
createReceiver
QueueReceiver createReceiver(Queue queue) throws JMSException
Creates aQueueReceiver
object to receive messages from the specified queue.- Parameters:
queue
- theQueue
to access- Throws:
JMSException
- if the session fails to create a receiver due to some internal error.InvalidDestinationException
- if an invalid queue is specified.
-
createReceiver
QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException
Creates aQueueReceiver
object to receive messages from the specified queue using a message selector.- Parameters:
queue
- theQueue
to accessmessageSelector
- only 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.- Throws:
JMSException
- if the session fails to create a receiver due to some internal error.InvalidDestinationException
- if an invalid queue is specified.InvalidSelectorException
- if the message selector is invalid.
-
createSender
QueueSender createSender(Queue queue) throws JMSException
Creates aQueueSender
object to send messages to the specified queue.- Parameters:
queue
- theQueue
to access, or null if this is an unidentified producer- Throws:
JMSException
- if the session fails to create a sender due to some internal error.InvalidDestinationException
- if an invalid queue is specified.
-
createBrowser
QueueBrowser createBrowser(Queue queue) throws JMSException
Creates aQueueBrowser
object to peek at the messages on the specified queue.- Specified by:
createBrowser
in interfaceSession
- Parameters:
queue
- theQueue
to access- Throws:
JMSException
- if the session fails to create a browser due to some internal error.InvalidDestinationException
- if an invalid queue is specified.
-
createBrowser
QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException
Creates aQueueBrowser
object to peek at the messages on the specified queue using a message selector.- Specified by:
createBrowser
in interfaceSession
- Parameters:
queue
- theQueue
to accessmessageSelector
- only 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.- Throws:
JMSException
- if the session fails to create a browser due to some internal error.InvalidDestinationException
- if an invalid queue is specified.InvalidSelectorException
- if the message selector is invalid.
-
createTemporaryQueue
TemporaryQueue createTemporaryQueue() throws JMSException
Creates aTemporaryQueue
object. Its lifetime will be that of theQueueConnection
unless it is deleted earlier.- Specified by:
createTemporaryQueue
in interfaceSession
- Returns:
- a temporary queue identity
- Throws:
JMSException
- if the session fails to create a temporary queue due to some internal error.
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/jms/QueueSession.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.