com.softwareag.entirex.aci
Class PublicationListener

java.lang.Object
  extended by java.lang.Thread
      extended by com.softwareag.entirex.aci.PublicationListener
All Implemented Interfaces:
java.lang.Runnable

public class PublicationListener
extends java.lang.Thread

A simple listener for publications. This listener starts receiving after calling start. To stop the listener, use stopListener. The listener stops after a wait time of 10 seconds. If the listener receives the last message of a publication, it commits this publication and starts receiving messages with a new publication.

Since:
7.2.1

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PublicationListener(Broker broker, java.lang.String topicName, java.lang.String wait, MessageListener listener)
          Creates a PublicationListener with a MessageListener.
 
Method Summary
 BrokerException getLastException()
          Gets the last BrokerException which occurred in the run method of this listener.
 void run()
          Receives messages in publications.
 void stopListener()
          Stop the listener.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PublicationListener

public PublicationListener(Broker broker,
                           java.lang.String topicName,
                           java.lang.String wait,
                           MessageListener listener)
Creates a PublicationListener with a MessageListener.

Parameters:
broker - the Broker object.
topicName - the name of the topic.
wait - the wait time for the receive calls.
listener - the object implementing the onMessage method.
Method Detail

run

public void run()
Receives messages in publications. If the last message in a publication is received, the current publication is committed and a new publication is received. The method returns if it is stopped with stopListener or if a BrokerException occurs.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stopListener

public void stopListener()
Stop the listener. The listener waits for the current receive call to return and then it stops.


getLastException

public BrokerException getLastException()
Gets the last BrokerException which occurred in the run method of this listener.

Returns:
the latest BrokerException.