Common API

This section covers the common API new to JMS 1.1 that bridges the point-to-point and publish-and-subscribe APIs. The common API interfaces can be used with both queues and topics.

Connection

The Connection is the base interface for the TopicConnection and the QueueConnection, and represents an open TCP/IP socket to the JMS provider. It defines several general-purpose methods used by clients of the messaging system in managing a JMS connection. Among these methods are the getMetaData(), start(), stop(), and close() methods:

public interface Connection {

    public Session createSession(boolean transacted,
           int acknowledgeMode) throws JMSException;
    
    public ExceptionListener getExceptionListener() throws JMSException; 
    public void setExceptionListener(ExceptionListener listener) 
       throws JMSException; 

    public ConnectionMetaData getMetaData() throws JMSException; 

    public String getClientID() throws JMSException;
    public void setClientID(String clientID) throws JMSException; 

    public void start() throws JMSException; 
    public void stop() throws JMSException;
    public void close() throws JMSException;

    public ConnectionConsumer createConnectionConsumer
                                 (Destination destination,
                                 String messageSelector,
                                 ServerSessionPool sessionPool,
                                 int maxMessages)
       throws JMSException;
}

A Connection object represents a physical connection to a JMS provider for either point-to-point (QueueConnection) or publish-and-subscribe (TopicConnection) messaging. A JMS client might choose to create multiple connections from ...

Get Java Message Service, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.