23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A.1.2 Connection<br />

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

The Connection is the base interface for the TopicConnection and the QueueConnection. It<br />

defines several general-purpose methods used by clients of the messaging system in<br />

managing a JMS connection. Among these methods are the getMetaData( ), start( ),<br />

stop( ), and close( ) methods:<br />

public interface Connection {<br />

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

public String getClientID( ) throws JMSException;<br />

public ExceptionListener getExceptionListener( ) throws JMSException;<br />

public ConnectionMetaData getMetaData( ) throws JMSException;<br />

public void setClientID(java.lang.String clientID)<br />

throws JMSException;<br />

public void setExceptionListener(ExceptionListener listener)<br />

throws JMSException;<br />

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

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

}<br />

A Connection object represents a physical connection to a JMS provider for either point-topoint<br />

(QueueConnection) or publish-and-subscribe (TopicConnection) messaging. A JMS<br />

client might choose to create multiple connections from the same connection factory, but<br />

this is rare as connections are relatively expensive (each connection requires a network<br />

socket, I/O streams, memory, etc.). Creating multiple Session objects from the same<br />

Connection object is considered more efficient, because sessions share access to the same<br />

connection.<br />

A.1.3 ConnectionFactory<br />

The ConnectionFactory is the base type for the TopicConnectionFactory and the<br />

QueueConnectionFactory, which are used in the publish-and-subscribe and point-to-point<br />

messaging models, respectively.<br />

The ConnectionFactory is implemented differently by each vendor, so configuration<br />

options available vary from product to product. A connection factory might, for example,<br />

be configured to manufacture connections that use a particular protocol, security scheme,<br />

clustering strategy, etc.:<br />

public interface ConnectionFactory {<br />

}<br />

A.1.4 ConnectionMetaData<br />

This type of object is obtained from a Connection object (TopicConnection or<br />

QueueConnection). It provides information describing the JMS connection and the JMS<br />

provider. Information available includes the identity of the JMS provider, the JMS version<br />

supported by the provider, JMS provider version numbers, and the JMS properties<br />

supported:<br />

public interface ConnectionMetaData {<br />

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

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

public String getJMSProviderName( ) throws JMSException;<br />

public String getJMSVersion( ) throws JMSException;<br />

142

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

Saved successfully!

Ooh no, something went wrong!