Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq
Class ActiveMQConnectionConsumer  view ActiveMQConnectionConsumer download ActiveMQConnectionConsumer.java

java.lang.Object
  extended byorg.activemq.ActiveMQConnectionConsumer
All Implemented Interfaces:
ActiveMQMessageDispatcher, javax.jms.ConnectionConsumer

public class ActiveMQConnectionConsumer
extends java.lang.Object
implements javax.jms.ConnectionConsumer, ActiveMQMessageDispatcher

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.


Field Summary
private  boolean closed
           
private  ActiveMQConnection connection
           
private  org.activemq.message.ConsumerInfo consumerInfo
           
protected  org.activemq.io.util.MemoryBoundedQueue messageQueue
           
private  javax.jms.ServerSessionPool sessionPool
           
 
Constructor Summary
protected ActiveMQConnectionConsumer(ActiveMQConnection theConnection, javax.jms.ServerSessionPool theSessionPool, org.activemq.message.ConsumerInfo theConsumerInfo, int theMaximumMessages)
          Create a ConnectionConsumer
 
Method Summary
 void close()
          Closes the connection consumer.
 void dispatch(org.activemq.message.ActiveMQMessage message)
          Dispatch an ActiveMQMessage
private  void dispatchToQueue(org.activemq.message.ActiveMQMessage message)
           
private  void dispatchToSession(org.activemq.message.ActiveMQMessage message)
           
 javax.jms.ServerSessionPool getServerSessionPool()
          Gets the server session pool associated with this connection consumer.
 boolean isTarget(org.activemq.message.ActiveMQMessage message)
          Tests to see if the Message Dispatcher is a target for this message
 org.activemq.message.ActiveMQMessage receive(long timeout)
          Receives the next message that arrives within the specified timeout interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

private ActiveMQConnection connection

sessionPool

private javax.jms.ServerSessionPool sessionPool

consumerInfo

private org.activemq.message.ConsumerInfo consumerInfo

closed

private boolean closed

messageQueue

protected org.activemq.io.util.MemoryBoundedQueue messageQueue
Constructor Detail

ActiveMQConnectionConsumer

protected ActiveMQConnectionConsumer(ActiveMQConnection theConnection,
                                     javax.jms.ServerSessionPool theSessionPool,
                                     org.activemq.message.ConsumerInfo theConsumerInfo,
                                     int theMaximumMessages)
                              throws javax.jms.JMSException
Create a ConnectionConsumer

Method Detail

isTarget

public boolean isTarget(org.activemq.message.ActiveMQMessage message)
Tests to see if the Message Dispatcher is a target for this message

Specified by:
isTarget in interface ActiveMQMessageDispatcher

dispatch

public void dispatch(org.activemq.message.ActiveMQMessage message)
Dispatch an ActiveMQMessage

Specified by:
dispatch in interface ActiveMQMessageDispatcher

dispatchToQueue

private void dispatchToQueue(org.activemq.message.ActiveMQMessage message)
                      throws javax.jms.JMSException

receive

public org.activemq.message.ActiveMQMessage receive(long timeout)
                                             throws javax.jms.JMSException
Receives the next message that arrives within the specified timeout interval.


dispatchToSession

private void dispatchToSession(org.activemq.message.ActiveMQMessage message)
                        throws javax.jms.JMSException

getServerSessionPool

public javax.jms.ServerSessionPool getServerSessionPool()
                                                 throws javax.jms.JMSException
Gets the server session pool associated with this connection consumer.

Specified by:
getServerSessionPool in interface javax.jms.ConnectionConsumer

close

public void close()
           throws javax.jms.JMSException
Closes 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 interface javax.jms.ConnectionConsumer