O'Reilly - Java Message Service
O'Reilly - Java Message Service
O'Reilly - Java Message Service
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A.3 Publish-and-Subscribe API<br />
This section covers the topic-based API.<br />
A.3.1 TemporaryTopic<br />
<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />
A TemporaryTopic is created by a TopicSession. A temporary topic is associated with the<br />
connection that belongs to the TopicSession that created it. It is only active for the duration<br />
of the session's connection, and it is guaranteed to be unique across all connections. Since<br />
it is temporary it can't be durable - it lasts only as long as its associated client connection is<br />
active. In all other respects it is just like a "regular" topic. The TemporaryTopic is a subtype<br />
of the Topic interface.<br />
Since a temporary topic is created by a JMS client, it is unavailable to other JMS clients<br />
unless the topic identity is transferred using the JMSReplyTo header. While any client may<br />
publish messages on another client's temporary topic, only the sessions that are associated<br />
with the JMS client connection that created the temporary topic may subscribe to it. JMS<br />
clients can also, of course, publish messages to their own temporary topics:<br />
public interface TemporaryTopic extends Topic {<br />
public void delete( ) throws JMSException;<br />
}<br />
A.3.2 Topic<br />
The Topic is an administered object that acts as a handle or identifier for an actual topic,<br />
called a physical topic, on the messaging server. A physical topic is a channel to which<br />
many clients can subscribe and publish. When a JMS client delivers a <strong>Message</strong> object to a<br />
topic, all the clients subscribed to that topic receive the <strong>Message</strong>. The Topic is a subtype of<br />
the Destination interface:<br />
public interface Topic extends Destination {<br />
public String getTopicName( ) throws JMSException;<br />
public String toString( );<br />
}<br />
A.3.3 TopicConnection<br />
The TopicConnection is created by the TopicConnectionFactory. The TopicConnection<br />
represents a connection to the message server. Each TopicConnection created from a<br />
TopicConnectionFactory is a unique connection to the server. [B] The TopicConnection is a<br />
subtype of the Connection interface:<br />
[B] The actual physical network connection may or may not be unique, depending on the vendor.<br />
However, the connection is considered to be logically unique so authentication and connection<br />
control can be managed separately from other connections.<br />
public interface TopicConnection extends Connection {<br />
public TopicSession createTopicSession(boolean transacted,<br />
int acknowledgeMode)<br />
throws JMSException;<br />
public ConnectionConsumer createConnectionConsumer<br />
(Topic topic, String messageSelector,<br />
ServerSessionPool sessionPool,<br />
int max<strong>Message</strong>s)<br />
153