eneter.messaging.dataprocessing.messagequeueing
Class WorkingThread<TMessage>

java.lang.Object
  extended by eneter.messaging.dataprocessing.messagequeueing.WorkingThread<TMessage>
Type Parameters:
TMessage - type of the message processed by the thread

public class WorkingThread<TMessage>
extends java.lang.Object

Thread with the message queue. If a message is put to the queue, the thread removes it from the queue and calls a call-back method to process it.


Constructor Summary
WorkingThread()
           
 
Method Summary
 void enqueueMessage(TMessage message)
          Puts the message to the queue.
 void registerMessageHandler(IMethod1<TMessage> messageHandler)
          Registers the method handling messages from the queue and starts the thread reading messages from the queue.
 void unregisterMessageHandler()
          Unregisters the method handling messages from the queue and stops the thread reading messages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkingThread

public WorkingThread()
Method Detail

registerMessageHandler

public void registerMessageHandler(IMethod1<TMessage> messageHandler)
Registers the method handling messages from the queue and starts the thread reading messages from the queue.

Parameters:
messageHandler - Callback called from the working thread to process the message

unregisterMessageHandler

public void unregisterMessageHandler()
Unregisters the method handling messages from the queue and stops the thread reading messages.


enqueueMessage

public void enqueueMessage(TMessage message)
                    throws java.lang.Exception
Puts the message to the queue.

Parameters:
message - message
Throws:
java.lang.Exception