Package org.apache.activemq
Class ActiveMQConnectionConsumer
java.lang.Object
org.apache.activemq.ActiveMQConnectionConsumer
- All Implemented Interfaces:
jakarta.jms.ConnectionConsumer
,ActiveMQDispatcher
public class ActiveMQConnectionConsumer
extends Object
implements jakarta.jms.ConnectionConsumer, ActiveMQDispatcher
For application servers,
Connection
objects provide a special
facility for creating a ConnectionConsumer
(optional). The
messages it is to consume are specified by a Destination
and a
message selector. In addition, a ConnectionConsumer
must be
given a ServerSessionPool
to use for processing its messages.
Normally, when traffic is light, a ConnectionConsumer
gets a
ServerSession
from its pool, loads it with a single message,
and starts it. As traffic picks up, messages can back up. If this happens, a
ConnectionConsumer
can load each ServerSession
with more than one message. This reduces the thread context switches and
minimizes resource use at the expense of some serialization of message
processing.
- See Also:
-
Connection.createConnectionConsumer(jakarta.jms.Destination, java.lang.String, jakarta.jms.ServerSessionPool, int)
Connection.createDurableConnectionConsumer(jakarta.jms.Topic, java.lang.String, java.lang.String, jakarta.jms.ServerSessionPool, int)
QueueConnection.createConnectionConsumer(jakarta.jms.Queue, java.lang.String, jakarta.jms.ServerSessionPool, int)
TopicConnection.createConnectionConsumer(jakarta.jms.Topic, java.lang.String, jakarta.jms.ServerSessionPool, int)
TopicConnection.createDurableConnectionConsumer(jakarta.jms.Topic, java.lang.String, java.lang.String, jakarta.jms.ServerSessionPool, int)
-
Constructor Summary
ModifierConstructorDescriptionprotected
ActiveMQConnectionConsumer
(ActiveMQConnection theConnection, jakarta.jms.ServerSessionPool theSessionPool, ConsumerInfo theConsumerInfo) Create a ConnectionConsumer -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearMessagesInProgress
(AtomicInteger transportInterruptionProcessingComplete) void
close()
Closes the connection consumer.void
dispatch
(MessageDispatch messageDispatch) void
dispose()
jakarta.jms.ServerSessionPool
Gets the server session pool associated with this connection consumer.toString()
-
Constructor Details
-
ActiveMQConnectionConsumer
protected ActiveMQConnectionConsumer(ActiveMQConnection theConnection, jakarta.jms.ServerSessionPool theSessionPool, ConsumerInfo theConsumerInfo) throws jakarta.jms.JMSException Create a ConnectionConsumer- Parameters:
theConnection
-theSessionPool
-theConsumerInfo
-- Throws:
jakarta.jms.JMSException
-
-
Method Details
-
getServerSessionPool
public jakarta.jms.ServerSessionPool getServerSessionPool() throws jakarta.jms.JMSExceptionGets the server session pool associated with this connection consumer.- Specified by:
getServerSessionPool
in interfacejakarta.jms.ConnectionConsumer
- Returns:
- the server session pool used by this connection consumer
- Throws:
jakarta.jms.JMSException
- if the JMS provider fails to get the server session pool associated with this consumer due to some internal error.
-
close
public void close() throws jakarta.jms.JMSExceptionCloses the connection consumer.Since a provider may allocate some resources on behalf of a connection consumer outside the Java virtual machine, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
- Specified by:
close
in interfacejakarta.jms.ConnectionConsumer
- Throws:
jakarta.jms.JMSException
-
dispose
public void dispose() -
dispatch
- Specified by:
dispatch
in interfaceActiveMQDispatcher
-
toString
-
clearMessagesInProgress
-
getConsumerInfo
-