OSMQ
v2.0.1

osmq.clients
Class SubscriberBean

java.lang.Object
  extended byosmq.clients.SubscriberBean
All Implemented Interfaces:
ClientAdapter, Subscriber

public class SubscriberBean
extends java.lang.Object
implements Subscriber

A class used by client applications to receive messages. The SubscriberBean 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.


Constructor Summary
SubscriberBean()
           
SubscriberBean(RemoteService rs)
           
SubscriberBean(osmq.clients.SubConnectionHandler connectionhandler)
           
 
Method Summary
 void addTopic(java.lang.String topic)
          Registers a topic for this subscriber.
 void close()
          Closes the message queues and halts message flow to the subscriber.
 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()
           
 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()
          Returns the message broker's host address as a DNS host name or IP address.
 MessageListener getMessageListener()
          Returns a reference to the MessageListener object that currently receives all topical and point-to-point messages for this client.
 int getPortID()
          Returns the port ID that will be used to connect to the message broker.
 SubscriberCountManager getSessionCount()
          Returns a SubscriberCountManager that accumulates message counts for this ClientSubscriber instance.
 int getThreadPriority()
          Returns the thread priority that will be used by the message subscriber thread.
 boolean isOpen()
          Returns true if the open() method was called.
 boolean isPersistentTopics()
          Returns true if the session is using persistent topics.
 void open()
          Commences sending messages to the MessageListeners that have been registered by this ClientSubscriber instance.
 void removeTopic(java.lang.String topic)
          Terminates receiving messages for 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 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 setMessageListener(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 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)
          Sets the thread priority for the subscriber notification thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubscriberBean

public SubscriberBean()

SubscriberBean

public SubscriberBean(RemoteService rs)

SubscriberBean

public SubscriberBean(osmq.clients.SubConnectionHandler connectionhandler)
Method Detail

addTopic

public final void addTopic(java.lang.String topic)
                    throws java.io.IOException
Registers a topic for this subscriber. When the broker connection is opened, all broker messages with a matching topic will be routed to the MessageListener instance that was registered by this subsriber. The Subscriber supports subscribing to one or more topics.

Specified by:
addTopic in interface Subscriber
Throws:
java.io.IOException
See Also:
setMessageListener(MessageListener), open()

getConnectionHandler

public osmq.clients.SubConnectionHandler getConnectionHandler()

removeTopic

public final void removeTopic(java.lang.String topic)
                       throws java.io.IOException
Terminates receiving messages for a specific topic.

Specified by:
removeTopic in interface Subscriber
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.

Specified by:
setExceptionListener in interface Subscriber

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.

Specified by:
getExceptionListener in interface Subscriber

setMessageListener

public final void setMessageListener(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.

Specified by:
setMessageListener in interface Subscriber

getMessageListener

public MessageListener getMessageListener()
Description copied from interface: Subscriber
Returns a reference to the MessageListener object that currently receives all topical and point-to-point messages for this client.

Specified by:
getMessageListener in interface Subscriber
See Also:
Subscriber.setMessageListener(MessageListener)

setThreadPriority

public void setThreadPriority(int priority)
Description copied from interface: Subscriber
Sets the thread priority for the subscriber notification thread. This overrides the default priority of NORMAL.

Specified by:
setThreadPriority in interface Subscriber

getThreadPriority

public int getThreadPriority()
Description copied from interface: Subscriber
Returns the thread priority that will be used by the message subscriber thread.

Specified by:
getThreadPriority in interface Subscriber
Returns:
true of there is a non-null value at position p, else false

getConnectionCount

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

Specified by:
getConnectionCount in interface Subscriber

getSessionCount

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

Specified by:
getSessionCount in interface Subscriber

setPersistentTopics

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

Specified by:
setPersistentTopics in interface Subscriber

isPersistentTopics

public boolean isPersistentTopics()
Description copied from interface: Subscriber
Returns true if the session is using persistent topics. Persistent topics will result in messages being queueud for the subscriber even after the subscriber disconnects from the broker. This is the default state.

Specified by:
isPersistentTopics in interface Subscriber

close

public void close()
Description copied from interface: Subscriber
Closes the message queues and halts message flow to the subscriber.

Specified by:
close in interface Subscriber

isOpen

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

Specified by:
isOpen in interface Subscriber

setClientID

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

Specified by:
setClientID in interface 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.

Specified by:
getClientID in interface Subscriber

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.

Specified by:
setPortID in interface Subscriber

getPortID

public int getPortID()
Description copied from interface: Subscriber
Returns the port ID that will be used to connect to the message broker. A value of 0 indicates that dynamic discovery will be used to identify the broker port.

Specified by:
getPortID in interface Subscriber
See Also:
Subscriber.setPortID(int)

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.

Specified by:
setHostName in interface Subscriber

getHostName

public java.lang.String getHostName()
Description copied from interface: Subscriber
Returns the message broker's host address as a DNS host name or IP address. This is the name that was set by the application. A value of null indicates that dynamic discovery will be used to identify the host address.

Specified by:
getHostName in interface Subscriber
See Also:
Subscriber.setHostName(String)

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.

Specified by:
setBrokerName in interface Subscriber

getBrokerName

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

Specified by:
getBrokerName in interface Subscriber

open

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

Specified by:
open in interface Subscriber
Throws:
java.io.IOException
See Also:
Subscriber.setMessageListener(MessageListener), Subscriber.close()

(c) 2000 - 2003 MQue Systems
All Rights Reserved