org.apache.activemq.pool
Class PooledConnection

java.lang.Object
  extended by org.apache.activemq.pool.PooledConnection
All Implemented Interfaces:
Connection, QueueConnection, TopicConnection, Closeable, EnhancedConnection

public class PooledConnection
extends Object
implements TopicConnection, QueueConnection, EnhancedConnection

Represents a proxy Connection which is-a TopicConnection and QueueConnection which is pooled and on close() will return itself to the sessionPool. NOTE this implementation is only intended for use when sending messages. It does not deal with pooling of consumers; for that look at a library like Jencks such as in this example

Version:
$Revision: 1.1.1.1 $

Constructor Summary
PooledConnection(ConnectionPool pool)
           
 
Method Summary
protected  void assertNotClosed()
           
 void close()
          Closes a JMS object.
 ConnectionConsumer createConnectionConsumer(Destination destination, String selector, ServerSessionPool serverSessionPool, int maxMessages)
           
 ConnectionConsumer createConnectionConsumer(Queue queue, String selector, ServerSessionPool serverSessionPool, int maxMessages)
           
 ConnectionConsumer createConnectionConsumer(Topic topic, String s, ServerSessionPool serverSessionPool, int maxMessages)
           
 ConnectionConsumer createDurableConnectionConsumer(Topic topic, String selector, String s1, ServerSessionPool serverSessionPool, int i)
           
 QueueSession createQueueSession(boolean transacted, int ackMode)
           
 Session createSession(boolean transacted, int ackMode)
           
protected  ActiveMQSession createSession(SessionKey key)
           
 TopicSession createTopicSession(boolean transacted, int ackMode)
           
 String getClientID()
           
 DestinationSource getDestinationSource()
          Returns the DestinationSource object which can be used to listen to destinations being created or destroyed or to enquire about the current destinations available on the broker
 ExceptionListener getExceptionListener()
           
 ConnectionMetaData getMetaData()
           
 PooledConnection newInstance()
          Factory method to create a new instance.
 void setClientID(String clientID)
           
 void setExceptionListener(ExceptionListener exceptionListener)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PooledConnection

public PooledConnection(ConnectionPool pool)
Method Detail

newInstance

public PooledConnection newInstance()
Factory method to create a new instance.


close

public void close()
           throws JMSException
Description copied from interface: Closeable
Closes a JMS object.

Many JMS objects are closeable such as Connections, Sessions, Consumers and Producers.

Specified by:
close in interface Connection
Specified by:
close in interface Closeable
Throws:
JMSException - if the JMS provider fails to close the object due to some internal error.

start

public void start()
           throws JMSException
Specified by:
start in interface Connection
Throws:
JMSException

stop

public void stop()
          throws JMSException
Specified by:
stop in interface Connection
Throws:
JMSException

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Destination destination,
                                                   String selector,
                                                   ServerSessionPool serverSessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface Connection
Throws:
JMSException

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Topic topic,
                                                   String s,
                                                   ServerSessionPool serverSessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface TopicConnection
Throws:
JMSException

createDurableConnectionConsumer

public ConnectionConsumer createDurableConnectionConsumer(Topic topic,
                                                          String selector,
                                                          String s1,
                                                          ServerSessionPool serverSessionPool,
                                                          int i)
                                                   throws JMSException
Specified by:
createDurableConnectionConsumer in interface Connection
Specified by:
createDurableConnectionConsumer in interface TopicConnection
Throws:
JMSException

getClientID

public String getClientID()
                   throws JMSException
Specified by:
getClientID in interface Connection
Throws:
JMSException

getExceptionListener

public ExceptionListener getExceptionListener()
                                       throws JMSException
Specified by:
getExceptionListener in interface Connection
Throws:
JMSException

getMetaData

public ConnectionMetaData getMetaData()
                               throws JMSException
Specified by:
getMetaData in interface Connection
Throws:
JMSException

setExceptionListener

public void setExceptionListener(ExceptionListener exceptionListener)
                          throws JMSException
Specified by:
setExceptionListener in interface Connection
Throws:
JMSException

setClientID

public void setClientID(String clientID)
                 throws JMSException
Specified by:
setClientID in interface Connection
Throws:
JMSException

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Queue queue,
                                                   String selector,
                                                   ServerSessionPool serverSessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface QueueConnection
Throws:
JMSException

createQueueSession

public QueueSession createQueueSession(boolean transacted,
                                       int ackMode)
                                throws JMSException
Specified by:
createQueueSession in interface QueueConnection
Throws:
JMSException

createTopicSession

public TopicSession createTopicSession(boolean transacted,
                                       int ackMode)
                                throws JMSException
Specified by:
createTopicSession in interface TopicConnection
Throws:
JMSException

createSession

public Session createSession(boolean transacted,
                             int ackMode)
                      throws JMSException
Specified by:
createSession in interface Connection
Throws:
JMSException

getDestinationSource

public DestinationSource getDestinationSource()
                                       throws JMSException
Description copied from interface: EnhancedConnection
Returns the DestinationSource object which can be used to listen to destinations being created or destroyed or to enquire about the current destinations available on the broker

Specified by:
getDestinationSource in interface EnhancedConnection
Returns:
a lazily created destination source
Throws:
JMSException

assertNotClosed

protected void assertNotClosed()
                        throws AlreadyClosedException
Throws:
AlreadyClosedException

createSession

protected ActiveMQSession createSession(SessionKey key)
                                 throws JMSException
Throws:
JMSException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.