OSMQ
v2.0.1

osmq.clients
Class TopicSubscriberBean

java.lang.Object
  extended byosmq.clients.TopicSubscriberBean

public class TopicSubscriberBean
extends java.lang.Object

A class used by client applications to receive messages. The TopicSubscriberBean connects to a message broker and allows the client application to subscribe to topical messages and receive both publish / subscribe and point-to-point (addressed) message.

Unlike the SubscriberBean, this class uses a seperate MessageListener registered for each topic.


Constructor Summary
TopicSubscriberBean()
           
 
Method Summary
 void addTopic(java.lang.String topic, MessageListener ml)
          Adds a topical listener -- one that subscribes to a named topic.
 void close()
           
 java.lang.String getBrokerName()
          Returns the name of the remote message broker for this session.
 java.lang.String getClientID()
          Returns the client identifier used by this session to communicate with the message broker.
 SubscriberCountManager getConnectionCount()
          Returns a SubscriberCountManager that accumulates message counts for all ClientSubcribers associated with this connection.
 osmq.clients.SubConnectionHandler getConnectionHandler()
           
 MessageListener getDefaultMessageListener()
           
 ExceptionListener getExceptionListener()
          Return the ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.
 java.lang.String getHostName()
           
 int getPortID()
           
 SubscriberCountManager getSessionCount()
          Returns a SubscriberCountManager that accumulates message counts for this ClientSubscriber instance.
 int getThreadPriority()
           
 int getTopicCount()
           
 boolean isOpen()
          Returns true if the open() method was called.
 boolean isPersistentTopics()
           
 void open()
          Commences sending messages to the MessageListeners that have been registered by this ClientSubscriber instance.
 void removeTopic(java.lang.String topic)
          Terminates sending messages to the listener of a specific topic.
 void setBrokerName(java.lang.String broker)
          Defines (overrides) the named message broker to be used for message processing (sending and receiving).
 void setClientID(java.lang.String id)
          Sets the identity of the application as a message recipient/subscriber
 void setDefaultMessageListener(MessageListener listener)
          Defines the listener that will be passed a Message when a one arrives that is addressed specificially to this client or contains a topic to which the client has subscribed.
 void setExceptionListener(ExceptionListener listener)
          Sets an ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.
 void setHostName(java.lang.String hostname)
          Overrides the host name / IP address of the remote server;
 void setPersistentTopics(boolean b)
          A method used to identify whether topical message subscription should persist after the ClientSubscriber has terminated.
 void setPortID(int port)
          Overrides the port id of the remote server;
 void setThreadPriority(int priority)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopicSubscriberBean

public TopicSubscriberBean()
Method Detail

addTopic

public final void addTopic(java.lang.String topic,
                           MessageListener ml)
                    throws java.io.IOException
Adds a topical listener -- one that subscribes to a named topic.

NOTE The application should include no more than 1 listener for any named topic.

Throws:
java.io.IOException - if attempt to add a topic that is already added

getTopicCount

public int getTopicCount()

getConnectionHandler

public osmq.clients.SubConnectionHandler getConnectionHandler()

removeTopic

public final void removeTopic(java.lang.String topic)
                       throws java.io.IOException
Terminates sending messages to the listener of a specific topic.

Throws:
java.io.IOException

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Sets an ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.


getExceptionListener

public ExceptionListener getExceptionListener()
Return the ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.


setDefaultMessageListener

public final void setDefaultMessageListener(MessageListener listener)
Defines the listener that will be passed a Message when a one arrives that is addressed specificially to this client or contains a topic to which the client has subscribed.


getDefaultMessageListener

public MessageListener getDefaultMessageListener()

setThreadPriority

public void setThreadPriority(int priority)

getThreadPriority

public int getThreadPriority()

getConnectionCount

public SubscriberCountManager getConnectionCount()
Returns a SubscriberCountManager that accumulates message counts for all ClientSubcribers associated with this connection.


getSessionCount

public SubscriberCountManager getSessionCount()
Returns a SubscriberCountManager that accumulates message counts for this ClientSubscriber instance.


setPersistentTopics

public void setPersistentTopics(boolean b)
A method used to identify whether topical message subscription should persist after the ClientSubscriber has terminated.


isPersistentTopics

public boolean isPersistentTopics()

close

public void close()

isOpen

public boolean isOpen()
Returns true if the open() method was called.


setClientID

public void setClientID(java.lang.String id)
Sets the identity of the application as a message recipient/subscriber

Parameters:
id - a unique name identifying the client application to the message broker.

getClientID

public java.lang.String getClientID()
Returns the client identifier used by this session to communicate with the message broker.


setPortID

public void setPortID(int port)
Overrides the port id of the remote server;

NOTE: Normally this method should NOT be called by the client application.


getPortID

public int getPortID()

setHostName

public void setHostName(java.lang.String hostname)
Overrides the host name / IP address of the remote server;

NOTE: Normally this method should NOT be called by the client application.


getHostName

public java.lang.String getHostName()

setBrokerName

public void setBrokerName(java.lang.String broker)
Defines (overrides) the named message broker to be used for message processing (sending and receiving). Generally, this method should not be called. Rather, the default broker should be used, especially in a production environment.


getBrokerName

public java.lang.String getBrokerName()
Returns the name of the remote message broker for this session.


open

public void open()
          throws java.io.IOException
Commences sending messages to the MessageListeners that have been registered by this ClientSubscriber instance.

Throws:
java.io.IOException

(c) 2000 - 2003 MQue Systems
All Rights Reserved