23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A.1.15 Session<br />

<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />

The Session is the base interface for the TopicSession and the QueueSession. It defines<br />

several general-purpose methods used by JMS clients for managing a JMS Session.<br />

Among these methods are the six create<strong>Message</strong>( ) methods (one for each type of <strong>Message</strong><br />

object), set<strong>Message</strong>Listener( ), close( ), and transaction methods.<br />

A Session is a single-threaded context for producing and consuming messages. It creates<br />

message consumers, producers, and messages for a specific JMS provider. The Session<br />

manages the scope of transactions across send and receive operations, tracks message<br />

acknowledgment for consumers, and serializes delivery of messages to <strong>Message</strong>Listener<br />

objects:<br />

public interface Session extends java.lang.Runnable {<br />

public static final int AUTO_ACKNOWLEDGE = 1;<br />

public static final int CLIENT_ACKNOWLEDGE = 2;<br />

public static final int DUPS_OK_ACKNOWLEDGE = 3;<br />

}<br />

public Bytes<strong>Message</strong> createBytes<strong>Message</strong>( ) throws JMSException;<br />

public Map<strong>Message</strong> createMap<strong>Message</strong>( ) throws JMSException;<br />

public <strong>Message</strong> create<strong>Message</strong>( ) throws JMSException;<br />

public Object<strong>Message</strong> createObject<strong>Message</strong>( ) throws JMSException;<br />

public Object<strong>Message</strong> createObject<strong>Message</strong>(Serializable object)<br />

throws JMSException;<br />

public Stream<strong>Message</strong> createStream<strong>Message</strong>( ) throws JMSException;<br />

public Text<strong>Message</strong> createText<strong>Message</strong>( ) throws JMSException;<br />

public Text<strong>Message</strong> createText<strong>Message</strong>(java.lang.String text)<br />

throws JMSException;<br />

public boolean getTransacted( ) throws JMSException;<br />

public void commit( ) throws JMSException;<br />

public void rollback( ) throws JMSException;<br />

public void close( ) throws JMSException;<br />

public void recover( ) throws JMSException;<br />

public <strong>Message</strong>Listener get<strong>Message</strong>Listener( ) throws JMSException;<br />

public void set<strong>Message</strong>Listener(<strong>Message</strong>Listener listener)<br />

throws JMSException;<br />

public void run( );<br />

A.1.16 Stream<strong>Message</strong><br />

This <strong>Message</strong> type carries a stream of primitive <strong>Java</strong> types (int, double, char, etc.) as its<br />

payload. It provides a set of convenience methods for mapping a formatted stream of bytes<br />

to <strong>Java</strong> primitives. It provides an easy programming model for exchanging primitive<br />

application data in a fixed order:<br />

public interface Stream<strong>Message</strong> extends <strong>Message</strong> {<br />

public boolean readBoolean( ) throws JMSException;<br />

public void writeBoolean(boolean value) throws JMSException;<br />

public byte readByte( ) throws JMSException;<br />

public int readBytes(byte[] value) throws JMSException;<br />

public void writeByte(byte value) throws JMSException;<br />

public void writeBytes(byte[] value) throws JMSException;<br />

public void writeBytes(byte[] value, int offset, int length)<br />

throws JMSException;<br />

public short readShort( ) throws JMSException;<br />

public void writeShort(short value) throws JMSException;<br />

public char readChar( ) throws JMSException;<br />

public void writeChar(char value) throws JMSException;<br />

public int readInt( ) throws JMSException;<br />

149

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!