org.exolab.jms.client
Class JmsTopicConnectionConsumer

java.lang.Object
  |
  +--org.exolab.jms.client.JmsConnectionConsumer
        |
        +--org.exolab.jms.client.JmsTopicConnectionConsumer
All Implemented Interfaces:
javax.jms.ConnectionConsumer, javax.jms.MessageListener

public class JmsTopicConnectionConsumer
extends org.exolab.jms.client.JmsConnectionConsumer

This class is part of the application server facility that allows concurrent processing of messages on the client side. An instance of this class is created given a JmsTopicSession a selector, session pool and the maximum number of messages that a particular session from the pool

This class maps back to a single JMS server session object. It registers a listener and caches messages locally. When messages arrive it will try grab a server session from the pool, load it with one or more message and then start it. The server session will deliver messages to the registered client.

The number of messages that are loaded on the server session is dependent on the load of the system. On lightly loaded system, where server sessions are readily available then this object may only load a single message. Conversely, in a heavily loaded system this object may load several messages into the one server session object to minimize context switches.

Version:
$Revision: 1.4 $ $Date: 2003/08/17 01:32:21 $
Author:
Jim Alateras
See Also:
JmsTopicConnection

Constructor Summary
JmsTopicConnectionConsumer(JmsTopicSession session, javax.jms.Topic topic, javax.jms.ServerSessionPool pool, java.lang.String selector, int maxMessages)
          Construct a new JmsTopicConnectionConsumer
JmsTopicConnectionConsumer(JmsTopicSession session, javax.jms.Topic topic, java.lang.String name, javax.jms.ServerSessionPool pool, java.lang.String selector, int maxMessages)
          Construct a new JmsTopicConnectionConsumer, for a durable connection consumer object.
 
Method Summary
 void close()
          Since a provider may allocate some resources on behalf of a ConnectionConsumer outside the JVM, clients should close them when they are not needed.
 javax.jms.ServerSessionPool getServerSessionPool()
          Return a reference ot the server session pool instance use by this object
 void onMessage(javax.jms.Message message)
          Impmentation of MessageListener.onMessage, which will receive messages from the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmsTopicConnectionConsumer

public JmsTopicConnectionConsumer(JmsTopicSession session,
                                  javax.jms.Topic topic,
                                  javax.jms.ServerSessionPool pool,
                                  java.lang.String selector,
                                  int maxMessages)
                           throws javax.jms.JMSException
Construct a new JmsTopicConnectionConsumer

The method takes a topic, which specified what topic it will receive messages for, a sessionPool, which it uses to source all its server session objects, a messageSelector, which is used to filter messages a null or empty messageSelector implies no filtering. This constructor also takes the maxMessages, which identifies the maximum number of messages it can send down each server session object.

Parameters:
session - server side session object
topic - which topic it will receive messges for
pool - the server session pool
selector - associated message selector, can be null
maxMessages - max number of messages it can send to down a server session object at any one time.
Throws:
javax.jms.JMSException -  

JmsTopicConnectionConsumer

public JmsTopicConnectionConsumer(JmsTopicSession session,
                                  javax.jms.Topic topic,
                                  java.lang.String name,
                                  javax.jms.ServerSessionPool pool,
                                  java.lang.String selector,
                                  int maxMessages)
                           throws javax.jms.JMSException
Construct a new JmsTopicConnectionConsumer, for a durable connection consumer object.
Parameters:
session - server side session object
topic - which topic it will receive messges for
name - subscription name, can be null
pool - the server session pool
selector - associated message selector, can be null
maxMessages - max number of messages it can send to down a server session object at any one time.
Throws:
javax.jms.JMSException -  
Method Detail

close

public void close()
           throws javax.jms.JMSException
Since a provider may allocate some resources on behalf of a ConnectionConsumer outside the JVM, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
Overrides:
close in class org.exolab.jms.client.JmsConnectionConsumer
Throws:
javax.jms.JMSException - if a JMS fails to release resources on behalf of ConnectionConsumer or it fails to close the connection consumer.

getServerSessionPool

public javax.jms.ServerSessionPool getServerSessionPool()
                                                 throws javax.jms.JMSException
Return a reference ot the server session pool instance use by this object

If the object is not set or there is any other issue throw the JMSException exception.

Specified by:
getServerSessionPool in interface javax.jms.ConnectionConsumer
Returns:
ServerSessionPool
Throws:
javax.jms.JMSException -  

onMessage

public void onMessage(javax.jms.Message message)
Impmentation of MessageListener.onMessage, which will receive messages from the server. In this most simply case it actually loads each individual message into a server session and calls the start method.

If this methods gets an error then it will send an error message to the logger and return successful

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
message - message send back by the server.


Copyright © 1999-2003 The OpenJMS Group. All Rights Reserved.