Class: Session

Session

Class that works as a context for producing and consuming messages.

new Session()

This method is not meant to be used directly. Creates a Session object that works as a context for producing and consuming messages.

Method Summary

close
Closes the session.
commit
Commits all messages done in this transaction.
createBytesMessage
Creates a new empty BytesMessage.
createConsumer
Creates a MessageConsumer for the specified destination, using a message selector.
createDurableConsumer
Creates a new durable MessageConsumer for receiving messages on a specific Topic.
createDurableSubscriber
Creates a new durable TopicSubscriber object for receiving messages on a specific Topic.
createMapMessage
Creates a new empty MapMessage.
createMessage
Creates a Message object.
createObjectMessage
Creates a new ObjectMessage with the specified object and class fully-qualified name as its payload.
createProducer
Creates a MessageProducer to send messages to the specified destination.
createQueue
Creates a new Queue object with the specified queue name.
createSharedConsumer
Creates shared a MessageConsumer for the specified topic, using the specified subscription name and a message selector.
createSharedDurableConsumer
Creates a new shared durable MessageConsumer for the specified topic, using the specified subscription name and a message selector.
createTemporaryQueue
Creates a TemporaryQueue object.
createTemporaryTopic
Creates a TemporaryTopic object.
createTextMessage
Creates a new TextMessage with the specified string as its payload.
createTopic
Creates a new Topic object with the specified topic name.
getAcknowledgeMode
Returns the acknowledgement mode of the session.
getTransacted
Indicates whether the session is in transacted mode.
recover
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.
rollback
Rolls back any messages done in this transaction.
unsubscribe
Unsubscribes a durable subscription previously created with the specified name.

Method Detail

close()

Closes the session. Once closed, any other method call will result in an IllegalStateException. A call to Session#close on a session that has already been closed is ignored.

commit()

Commits all messages done in this transaction.

createBytesMessage() → {BytesMessage}

Creates a new empty BytesMessage.
Returns:
Type
BytesMessage

createConsumer(destination, messageSelector, noLocal) → {MessageConsumer}

Creates a MessageConsumer for the specified destination, using a message selector.
Parameters:
Name Type Description
destination Destination destination from which the consumer must receive messages.
messageSelector String specifies the optional selector, e.g. the rule to be applied to messages being received to filter them or not. See JMS specifications for more information on message selectors.
noLocal Boolean specifies if this consumer must receive or not messages published by its own connection.
Returns:
Type
MessageConsumer

createDurableConsumer(topic, name, messageSelector, noLocal) → {MessageConsumer}

Creates a new durable MessageConsumer for receiving messages on a specific Topic. See JMS specifications for differences between durable and non durable consumers.
Parameters:
Name Type Description
topic Topic topic from which the subscriber must receive messages.
name String name of the subscription. See JMS specifications for more information.
messageSelector String specifies the optional selector, e.g. the rule to be applied to messages being received to filter them or not. See JMS specifications for more information on message selectors.
noLocal Boolean specifies if this consumer must receive or not messages published by its own connection.
Returns:
Type
MessageConsumer

createDurableSubscriber(topic, name, messageSelector, noLocal) → {TopicSubscriber}

Creates a new durable TopicSubscriber object for receiving messages on a specific Topic. See JMS specifications for differences between durable and non durable subscribers.
Parameters:
Name Type Description
topic Topic topic from which the subscriber must receive messages.
name String name of the durable subscription. See JMS specifications for more information.
messageSelector String specifies the optional selector, e.g. the rule to be applied to messages being received to filter them or not. See JMS specifications for more information on message selectors.
noLocal Boolean specifies if this consumer must receive or not messages published by its own connection.
Returns:
Type
TopicSubscriber

createMapMessage() → {MapMessage}

Creates a new empty MapMessage.
Returns:
Type
MapMessage

createMessage() → {Message}

Creates a Message object. The Message class is the root class of all JMS messages. A Message object holds all the standard message header information. It can be sent when a message containing only header information is sufficient.
Returns:
Type
Message

createObjectMessage(object, classFQN) → {ObjectMessage}

Creates a new ObjectMessage with the specified object and class fully-qualified name as its payload.
Parameters:
Name Type Description
object Object desired object payload for the message.
classFQN String fully-qualified class name of the payload object.
Returns:
Type
ObjectMessage

createProducer(destination) → {MessageProducer}

Creates a MessageProducer to send messages to the specified destination.
Parameters:
Name Type Description
destination Destination the Destination to send to.
Returns:
Type
MessageProducer

createQueue(queueName) → {Queue}

Creates a new Queue object with the specified queue name.
Parameters:
Name Type Description
queueName String name of the queue.
Returns:
Type
Queue

createSharedConsumer(topic, sharedSubscriptionName, messageSelector) → {MessageConsumer}

Creates shared a MessageConsumer for the specified topic, using the specified subscription name and a message selector. See JMS specifications for differences between shared and non shared consumers.
Parameters:
Name Type Description
topic Topic topic from which the consumer must receive messages.
sharedSubscriptionName String name of the shared subscription. See JMS specifications for more information.
messageSelector String specifies the optional selector, e.g. the rule to be applied to messages being received to filter them or not. See JMS specifications for more information on message selectors.
Returns:
Type
MessageConsumer

createSharedDurableConsumer(topic, name, messageSelector) → {MessageConsumer}

Creates a new shared durable MessageConsumer for the specified topic, using the specified subscription name and a message selector. See JMS specifications for differences between shared, non shared, durable and non durable consumers.
Parameters:
Name Type Description
topic Topic topic from which the consumer must receive messages.
name String name of the subscription. See JMS specifications for more information.
messageSelector String specifies the optional selector, e.g. the rule to be applied to messages being received to filter them or not. See JMS specifications for more information on message selectors.
Returns:
Type
MessageConsumer

createTemporaryQueue(onTempQueueCreated, onTempQueueFailed) → {TemporaryQueue}

Creates a TemporaryQueue object. Its lifetime will be that of the Connection unless it is deleted earlier.
Implementation note: due to limitations of Javascript this method can't return a temp queue synchronously, the queue will be delivered asynchronously through the specified callback.
Parameters:
Name Type Description
onTempQueueCreated function the callback that will be invoked when the temp queue is created. Takes one argument: the TemporaryQueue object.
onTempQueueFailed function the callback that will be invoked when the temp queue creation fails. Takes one argument: an exception.
Returns:
Type
TemporaryQueue

createTemporaryTopic(onTempTopicCreated, onTempTopicFailed) → {TemporaryTopic}

Creates a TemporaryTopic object. Its lifetime will be that of the Connection unless it is deleted earlier.
Implementation note: due to limitations of Javascript this method can't return a temp topic synchronously, the topic will be delivered asynchronously through the specified callback.
Parameters:
Name Type Description
onTempTopicCreated function the callback that will be invoked when the temp topic is created. Takes one argument: the TemporaryQueue object.
onTempTopicFailed function the callback that will be invoked when the temp topic creation fails. Takes one argument: an exception.
Returns:
Type
TemporaryTopic

createTextMessage(text) → {TextMessage}

Creates a new TextMessage with the specified string as its payload.
Parameters:
Name Type Description
text String desired string payload for the message.
Returns:
Type
TextMessage

createTopic(topicName) → {Topic}

Creates a new Topic object with the specified topic name.
Parameters:
Name Type Description
topicName String name of the topic.
Returns:
Type
Topic

getAcknowledgeMode() → {String}

Returns the acknowledgement mode of the session. The acknowledgement mode is set at the time that the session is created.
Returns:
Type
String

getTransacted() → {Boolean}

Indicates whether the session is in transacted mode.
Returns:
Type
Boolean

recover()

Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message. Redelivered messages do not have to be delivered in exactly their original delivery order. See JMS specifications for more information.

rollback()

Rolls back any messages done in this transaction.

unsubscribe(name)

Unsubscribes a durable subscription previously created with the specified name. See JMS specifications for more information on durable subscriptions.
Implementation note: if there's still an open consumer on the subscription, the unsubscribe will be automatically postponed to when the consumer will be closed.
Parameters:
Name Type Description
name String name used to identify this subscription.