WebSphere MQ class: MQSession
java.lang.Object | +----com.ibm.mq.jms.MQSession |
A JMS Session is a single threaded context for producing and consuming messages.
See also: QueueSession, TopicSession, XAQueueSession, XASession, and XATopicSession
public static final int AUTO_ACKNOWLEDGE
With this acknowledgement mode, the session automatically acknowledges a message when it has either successfully returned from a call to receive, or the message listener it has called to process the message successfully returns.
public static final int CLIENT_ACKNOWLEDGE
With this acknowledgement mode, the client acknowledges a message by calling a message's acknowledge method.
public static final int DUPS_OK_ACKNOWLEDGE
This acknowledgement mode instructs the session to lazily acknowledge the delivery of messages.
public void close() throws JMSException
Because a provider may allocate some resources outside of the JVM on behalf of a Session, clients should close them when they are not needed. You cannot rely on garbage collection to reclaim these resources eventually, because this may not occur soon enough.
Closing a transacted session rolls back any in-progress transaction. Closing a session automatically closes its message producers and consumer, so there is no need to close them individually.
public void commit() throws JMSException
Commit all messages done in this transaction and release any locks currently held.
WebSphere MQ Event Broker note |
---|
This always throws a JMSException when you have a direct connection to WebSphere MQ Event Broker. |
public BytesMessage createBytesMessage() throws JMSException
Create a BytesMessage. A BytesMessage is used to send a message containing a stream of uninterpreted bytes.
public MapMessage createMapMessage() throws JMSException
Create a MapMessage. A MapMessage is used to send a self-defining set of name-value pairs, where names are Strings, and values are Java primitive types.
public Message createMessage() throws JMSException
Create a Message. The Message interface is the root interface of all JMS messages. It holds all the standard message header information. It can be sent when a message containing only header information is sufficient.
public ObjectMessage createObjectMessage() throws JMSException
Create an ObjectMessage. An ObjectMessage is used to send a message that contains a serializable Java object.
public ObjectMessage createObjectMessage (java.io.Serializable object) throws JMSException
Create an initialized ObjectMessage. An ObjectMessage is used to send a message that contains a serializable Java object.
public StreamMessage createStreamMessage() throws JMSException
Create a StreamMessage. A StreamMessage is used to send a self-defining stream of Java primitives.
public TextMessage createTextMessage() throws JMSException
Create a TextMessage. A TextMessage is used to send a message containing a String.
public TextMessage createTextMessage (java.lang.String string) throws JMSException
Create an initialized TextMessage. A TextMessage is used to send a message containing a String.
public MessageListener getMessageListener() throws JMSException
Return the session's distinguished message listener.
public boolean getTransacted() throws JMSException
Is the session in transacted mode?
WebSphere MQ Event Broker note |
---|
This method always returns false when you have a direct connection to WebSphere MQ Event Broker. |
public void recover() throws JMSException
Stop message delivery in this session, and restart sending messages with the oldest unacknowledged message.
WebSphere MQ Event Broker note |
---|
This always throws a JMSException when you have a direct connection to WebSphere MQ Event Broker. |
public void rollback() throws JMSException
Roll back any messages done in this transaction and release any locks currently held.
WebSphere MQ Event Broker note |
---|
This always throws a JMSException when you have a direct connection to WebSphere MQ Event Broker. |
public void run()
This method is intended for use only by application servers.
WebSphere MQ Event Broker note |
---|
This always throws an IllegalStateException when you have a direct connection to WebSphere MQ Event Broker. |
public void setMessageListener(MessageListener listener) throws JMSException
Set the session's distinguished message listener. When it 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 that is not used by regular JMS clients.