org.mule.transport
Class AbstractMessageReceiver

java.lang.Object
  extended by org.mule.transport.AbstractTransportMessageHandler
      extended by org.mule.transport.AbstractMessageReceiver
All Implemented Interfaces:
Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable, MessageSource, Connectable, MessageReceiver
Direct Known Subclasses:
AbstractPollingMessageReceiver, AjaxMessageReceiver, AxisMessageReceiver, HttpMessageReceiver, JettyHttpMessageReceiver, JmsMessageReceiver, MultiConsumerJmsMessageReceiver, QuartzMessageReceiver, RmiCallbackMessageReceiver, ServletMessageReceiver, TcpMessageReceiver, TransactedSingleResourceJmsMessageReceiver, UdpMessageReceiver, XmppMessageReceiver

public abstract class AbstractMessageReceiver
extends AbstractTransportMessageHandler
implements MessageReceiver

AbstractMessageReceiver provides common methods for all Message Receivers provided with Mule. A message receiver enables an endpoint to receive a message from an external system.


Field Summary
protected  List<Transformer> defaultInboundTransformers
           
protected  List<Transformer> defaultResponseTransformers
           
protected  FlowConstruct flowConstruct
          The Service with which this receiver is associated with
protected  MessageProcessor listener
          MessageProcessor chain used to process messages once the transport specific MessageReceiver has received transport message and created the MuleEvent
protected  String receiverKey
          Stores the key to this receiver, as used by the Connector to store the receiver.
protected  ReplyToHandler replyToHandler
           
 
Fields inherited from class org.mule.transport.AbstractTransportMessageHandler
connected, connector, endpoint, lifecycleManager, logger, muleMessageFactory, retryTemplate
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
AbstractMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint)
          Creates the Message Receiver
 
Method Summary
protected  void applyInboundTransformers(MuleEvent event)
           
protected  void applyResponseTransformers(MuleEvent event)
           
protected  void connectHandler()
           
protected  ExecutionTemplate<MuleEvent> createExecutionTemplate()
           
protected  ConnectableLifecycleManager createLifecycleManager()
           
protected  MuleEvent createMuleEvent(MuleMessage message, OutputStream outputStream)
           
protected  void doDispose()
           
protected  void doStartHandler()
           
protected  void doStop()
           
protected  String getConnectEventId()
           
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 InboundEndpoint getEndpoint()
           
 EndpointURI getEndpointURI()
          The endpointUri that this receiver listens on
 FlowConstruct getFlowConstruct()
           
 String getReceiverKey()
           
protected  ReplyToHandler getReplyToHandler()
           
protected  WorkManager getWorkManager()
           
protected  MuleMessage handleUnacceptedFilter(MuleMessage message)
           
 void initialise()
          Method used to perform any initialisation work.
protected  void processMessage(MessageProcessTemplate messageProcessTemplate, MessageProcessContext messageProcessContext)
           
protected  void propagateRootMessageIdProperty(MuleMessage message)
           
 MuleEvent routeEvent(MuleEvent muleEvent)
           
 MuleEvent routeMessage(MuleMessage message)
           
 MuleEvent routeMessage(MuleMessage message, MuleSession session, OutputStream outputStream)
           
 MuleEvent routeMessage(MuleMessage message, MuleSession session, Transaction trans, OutputStream outputStream)
           
 MuleEvent routeMessage(MuleMessage message, Transaction trans)
           
 MuleEvent routeMessage(MuleMessage message, Transaction trans, OutputStream outputStream)
           
 void setEndpoint(InboundEndpoint endpoint)
           
 void setListener(MessageProcessor processor)
          Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.
 void setReceiverKey(String receiverKey)
           
 boolean shouldConsumeInEveryNode()
          Determines whether to start or not the MessageSource base on the running node state.
 String toString()
           
protected  void warnIfMuleClientSendUsed(MuleMessage message)
           
 
Methods inherited from class org.mule.transport.AbstractTransportMessageHandler
activate, connect, createMuleMessage, createMuleMessage, createMuleMessage, createMuleMessageFactory, createNullMuleMessage, disconnect, dispose, disposeAndLogException, doConnect, doDisconnect, doInitialise, doStart, getConnectEventId, getConnector, getLifecycleState, initializeMessageFactory, initializeRetryPolicy, isConnected, isDoThreading, isStarted, isStarting, isStopped, isStopping, passivate, setEndpoint, start, stop, validate, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transport.MessageReceiver
createMuleMessage, createMuleMessage
 
Methods inherited from interface org.mule.api.transport.Connectable
connect, disconnect, isConnected, validateConnection
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 

Field Detail

flowConstruct

protected FlowConstruct flowConstruct
The Service with which this receiver is associated with


listener

protected MessageProcessor listener
MessageProcessor chain used to process messages once the transport specific MessageReceiver has received transport message and created the MuleEvent


receiverKey

protected String receiverKey
Stores the key to this receiver, as used by the Connector to store the receiver.


defaultInboundTransformers

protected List<Transformer> defaultInboundTransformers

defaultResponseTransformers

protected List<Transformer> defaultResponseTransformers

replyToHandler

protected ReplyToHandler replyToHandler
Constructor Detail

AbstractMessageReceiver

public AbstractMessageReceiver(Connector connector,
                               FlowConstruct flowConstruct,
                               InboundEndpoint endpoint)
                        throws CreateException
Creates the Message Receiver

Parameters:
connector - the endpoint that created this listener
flowConstruct - the flow construct to associate with the receiver.
endpoint - the provider contains the endpointUri on which the receiver will listen on. The endpointUri can be anything and is specific to the receiver implementation i.e. an email address, a directory, a jms destination or port address.
Throws:
CreateException
See Also:
FlowConstruct, InboundEndpoint
Method Detail

createLifecycleManager

protected ConnectableLifecycleManager createLifecycleManager()
Specified by:
createLifecycleManager in class AbstractTransportMessageHandler

initialise

public final void initialise()
                      throws InitialisationException
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractTransportMessageHandler
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

getFlowConstruct

public FlowConstruct getFlowConstruct()
Specified by:
getFlowConstruct in interface MessageReceiver
Returns:
the service associated with the receiver

routeMessage

public final MuleEvent routeMessage(MuleMessage message)
                             throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleEvent routeMessage(MuleMessage message,
                                    Transaction trans)
                             throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleEvent routeMessage(MuleMessage message,
                                    Transaction trans,
                                    OutputStream outputStream)
                             throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleEvent routeMessage(MuleMessage message,
                                    MuleSession session,
                                    Transaction trans,
                                    OutputStream outputStream)
                             throws MuleException
Throws:
MuleException

routeMessage

public final MuleEvent routeMessage(MuleMessage message,
                                    MuleSession session,
                                    OutputStream outputStream)
                             throws MuleException
Throws:
MuleException

propagateRootMessageIdProperty

protected void propagateRootMessageIdProperty(MuleMessage message)

warnIfMuleClientSendUsed

protected void warnIfMuleClientSendUsed(MuleMessage message)

applyInboundTransformers

protected void applyInboundTransformers(MuleEvent event)
                                 throws MuleException
Throws:
MuleException

applyResponseTransformers

protected void applyResponseTransformers(MuleEvent event)
                                  throws MuleException
Throws:
MuleException

handleUnacceptedFilter

protected MuleMessage handleUnacceptedFilter(MuleMessage message)

createMuleEvent

protected MuleEvent createMuleEvent(MuleMessage message,
                                    OutputStream outputStream)
                             throws MuleException
Throws:
MuleException

getEndpointURI

public EndpointURI getEndpointURI()
Description copied from interface: MessageReceiver
The endpointUri that this receiver listens on

Specified by:
getEndpointURI in interface MessageReceiver

getConnectionDescription

public String getConnectionDescription()
Description copied from class: AbstractTransportMessageHandler
Returns a string identifying the underlying resource

Specified by:
getConnectionDescription in interface Connectable
Overrides:
getConnectionDescription in class AbstractTransportMessageHandler

getConnectEventId

protected String getConnectEventId()

setReceiverKey

public void setReceiverKey(String receiverKey)
Specified by:
setReceiverKey in interface MessageReceiver

getReceiverKey

public String getReceiverKey()
Specified by:
getReceiverKey in interface MessageReceiver

getEndpoint

public InboundEndpoint getEndpoint()
Specified by:
getEndpoint in interface MessageReceiver
Overrides:
getEndpoint in class AbstractTransportMessageHandler
Returns:
the endpoint from which we are receiving events

setEndpoint

public void setEndpoint(InboundEndpoint endpoint)
Specified by:
setEndpoint in interface MessageReceiver
Parameters:
endpoint - the endpoint to listen on
See Also:
ImmutableEndpoint

getWorkManager

protected WorkManager getWorkManager()
Specified by:
getWorkManager in class AbstractTransportMessageHandler

toString

public String toString()
Overrides:
toString in class AbstractTransportMessageHandler

setListener

public void setListener(MessageProcessor processor)
Description copied from interface: MessageSource
Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.

Specified by:
setListener in interface MessageSource

doDispose

protected void doDispose()
Overrides:
doDispose in class AbstractTransportMessageHandler

getReplyToHandler

protected ReplyToHandler getReplyToHandler()

createExecutionTemplate

protected ExecutionTemplate<MuleEvent> createExecutionTemplate()

shouldConsumeInEveryNode

public boolean shouldConsumeInEveryNode()
Determines whether to start or not the MessageSource base on the running node state.

Returns:
false if this MessageSource should be stated only in the primary node, true if it should be started in every node.

connectHandler

protected final void connectHandler()
                             throws Exception
Overrides:
connectHandler in class AbstractTransportMessageHandler
Throws:
Exception

doStartHandler

protected final void doStartHandler()
                             throws MuleException
Overrides:
doStartHandler in class AbstractTransportMessageHandler
Throws:
MuleException

doStop

protected void doStop()
               throws MuleException
Overrides:
doStop in class AbstractTransportMessageHandler
Throws:
MuleException

routeEvent

public MuleEvent routeEvent(MuleEvent muleEvent)
                     throws MuleException
Throws:
MuleException

processMessage

protected void processMessage(MessageProcessTemplate messageProcessTemplate,
                              MessageProcessContext messageProcessContext)


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