org.mule.transport
Class AbstractReceiverWorker

java.lang.Object
  extended by org.mule.transport.AbstractReceiverWorker
All Implemented Interfaces:
Runnable, javax.resource.spi.work.Work
Direct Known Subclasses:
AbstractReceiverResourceWorker, JmsMessageReceiver.JmsWorker, MultiConsumerJmsMessageReceiver.JmsWorker

public abstract class AbstractReceiverWorker
extends Object
implements javax.resource.spi.work.Work

A base Worker used by Transport MessageReceiver implementations.


Field Summary
protected  InboundEndpoint endpoint
           
protected  List<Object> messages
           
protected  OutputStream out
           
protected  AbstractMessageReceiver receiver
           
 
Constructor Summary
AbstractReceiverWorker(List<Object> messages, AbstractMessageReceiver receiver)
           
AbstractReceiverWorker(List<Object> messages, AbstractMessageReceiver receiver, OutputStream out)
           
 
Method Summary
protected abstract  void bindTransaction(Transaction tx)
          Template method used to bind the resources of this receiver to the transaction.
protected  void doRun()
           
protected  List handleEventResults(List<MuleEvent> messages)
           
protected  void handleResults(List messages)
          When Mule has finished processing the current messages, there may be zero or more messages to process by the receiver if request/response messaging is being used.
protected  MuleMessage postProcessMessage(MuleMessage message)
          If a result is returned back this method will get called before the message is added to te list of results (these are later passed to handleResults(java.util.List))
protected  Object preProcessMessage(Object message)
          Before a message is passed into Mule this callback is called and can be used by the worker to inspect the message before it gets sent to Mule
protected  void preRouteMuleMessage(MuleMessage message)
          This callback is called before a message is routed into Mule and can be used by the worker to set connection specific properties to message before it gets routed
 void processMessages()
          The actual logic used to receive messages from the underlying transport.
 void release()
          This method is called once this worker is no longer required.
 void run()
          This will run the receiver logic and call release() once doRun() completes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected List<Object> messages

endpoint

protected InboundEndpoint endpoint

receiver

protected AbstractMessageReceiver receiver

out

protected OutputStream out
Constructor Detail

AbstractReceiverWorker

public AbstractReceiverWorker(List<Object> messages,
                              AbstractMessageReceiver receiver)

AbstractReceiverWorker

public AbstractReceiverWorker(List<Object> messages,
                              AbstractMessageReceiver receiver,
                              OutputStream out)
Method Detail

run

public final void run()
This will run the receiver logic and call release() once doRun() completes.

Specified by:
run in interface Runnable

doRun

protected void doRun()

processMessages

public void processMessages()
                     throws Exception
The actual logic used to receive messages from the underlying transport. The default implementation will execute the processing of messages within a TransactionTemplate. This template will manage the transaction lifecycle for the list of messages associated with this receiver worker.

Throws:
Exception

handleEventResults

protected List handleEventResults(List<MuleEvent> messages)
                           throws Exception
Throws:
Exception

preRouteMuleMessage

protected void preRouteMuleMessage(MuleMessage message)
                            throws Exception
This callback is called before a message is routed into Mule and can be used by the worker to set connection specific properties to message before it gets routed

Parameters:
message - the next message to be processed
Throws:
Exception

bindTransaction

protected abstract void bindTransaction(Transaction tx)
                                 throws TransactionException
Template method used to bind the resources of this receiver to the transaction. Only transactional transports need implment this method

Parameters:
tx - the current transaction or null if there is no transaction
Throws:
TransactionException

handleResults

protected void handleResults(List messages)
                      throws Exception
When Mule has finished processing the current messages, there may be zero or more messages to process by the receiver if request/response messaging is being used. The result(s) should be passed back to the callee.

Parameters:
messages - a list of messages. This argument will not be null
Throws:
Exception

preProcessMessage

protected Object preProcessMessage(Object message)
                            throws Exception
Before a message is passed into Mule this callback is called and can be used by the worker to inspect the message before it gets sent to Mule

Parameters:
message - the next message to be processed
Returns:
the message to be processed. If Null is returned the message will not get processed.
Throws:
Exception

postProcessMessage

protected MuleMessage postProcessMessage(MuleMessage message)
                                  throws Exception
If a result is returned back this method will get called before the message is added to te list of results (these are later passed to handleResults(java.util.List))

Parameters:
message - the result message, this will never be null
Returns:
the message to add to the list of results. If null is returned nothing is added to the list of results
Throws:
Exception

release

public void release()
This method is called once this worker is no longer required. Any resources *only* associated with this worker should be cleaned up here.

Specified by:
release in interface javax.resource.spi.work.Work


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.