org.mule.routing.outbound
Class AbstractOutboundRouter

java.lang.Object
  extended by org.mule.processor.AbstractMuleObjectOwner<MessageProcessor>
      extended by org.mule.processor.AbstractMessageProcessorOwner
          extended by org.mule.routing.outbound.AbstractOutboundRouter
All Implemented Interfaces:
AnnotatedObject, FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, MessageProcessor, MessageRouter, Matchable, MatchableMessageProcessor, MatchableMessageRouter, OutboundRouter, RouterStatisticsRecorder
Direct Known Subclasses:
ContentBasedRouter, FilteringOutboundRouter, FirstSuccessful, RoundRobin, TransformerRouter, UntilSuccessful

public abstract class AbstractOutboundRouter
extends AbstractMessageProcessorOwner
implements OutboundRouter

AbstractOutboundRouter is a base router class that tracks statistics about message processing through the router.


Field Summary
protected  CorrelationMode enableCorrelation
          Determines if Mule stamps outgoing message with a correlation ID or not.
protected  AtomicBoolean initialised
           
protected  Log logger
          logger used by this class
protected static List<String> magicProperties
          These properties are automatically propagated by Mule from inbound to outbound
protected  String replyTo
           
protected  RouterResultsHandler resultsHandler
           
protected  List<MessageProcessor> routes
           
protected  AtomicBoolean started
           
protected  TransactionConfig transactionConfig
           
 
Fields inherited from class org.mule.processor.AbstractMuleObjectOwner
flowConstruct, muleContext
 
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
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
AbstractOutboundRouter()
           
 
Method Summary
 void addRoute(MessageProcessor route)
          Adds a new message processor to the list of routes
protected  MuleMessage cloneMessage(MuleMessage message)
          Create a fresh copy of a message.
protected  MuleEvent createEventToRoute(MuleEvent routedEvent, MuleMessage message, MessageProcessor route)
          Create a new event to be routed to the target MP
 void dispose()
          A lifecycle method where implementor should free up any resources.
 CorrelationMode getEnableCorrelation()
           
 MuleContext getMuleContext()
           
protected  List<MessageProcessor> getOwnedMessageProcessors()
           
 String getReplyTo()
           
 RouterResultsHandler getResultsHandler()
           
 MessageProcessor getRoute(String name)
           
 RouterStatistics getRouterStatistics()
           
 List<MessageProcessor> getRoutes()
          Gets a list of MessageProcessor instances associated with this router
 TransactionConfig getTransactionConfig()
           
 void initialise()
          Method used to perform any initialisation work.
 boolean isDynamicRoutes()
          Determines whether this router supports dynamic route.
 MuleEvent process(MuleEvent event)
          Invokes the MessageProcessor.
protected  void propagateMagicProperties(MuleMessage in, MuleMessage out)
          Propagates a number of internal system properties to handle correlation, session, etc.
 void removeRoute(MessageProcessor route)
          Removes a message processor from the list of routes
protected abstract  MuleEvent route(MuleEvent event)
           
protected  MuleEvent sendRequest(MuleEvent routedEvent, MuleMessage message, MessageProcessor route, boolean awaitResponse)
           
protected  MuleEvent sendRequestEvent(MuleEvent routedEvent, MuleMessage message, MessageProcessor route, boolean awaitResponse)
          Send message event to destination.
 void setEnableCorrelation(CorrelationMode enableCorrelation)
           
 void setEnableCorrelationAsString(String enableCorrelation)
           
 void setMessageProcessors(List<MessageProcessor> routes)
          Deprecated. 
protected  void setMessageProperties(FlowConstruct service, MuleMessage message, MessageProcessor route)
           
 void setReplyTo(String replyTo)
          Sets the replyTo route for any outgoing messages.
 void setResultsHandler(RouterResultsHandler resultsHandler)
           
 void setRouterStatistics(RouterStatistics stats)
           
 void setRoutes(List<MessageProcessor> routes)
           
 void setTransactionConfig(TransactionConfig transactionConfig)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.mule.processor.AbstractMessageProcessorOwner
getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
 
Methods inherited from class org.mule.processor.AbstractMuleObjectOwner
getFlowConstruct, setFlowConstruct, setMuleContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.routing.Matchable
isMatch
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.api.construct.FlowConstructAware
setFlowConstruct
 

Field Detail

magicProperties

protected static List<String> magicProperties
These properties are automatically propagated by Mule from inbound to outbound


logger

protected transient Log logger
logger used by this class


routes

protected List<MessageProcessor> routes

replyTo

protected String replyTo

enableCorrelation

protected CorrelationMode enableCorrelation
Determines if Mule stamps outgoing message with a correlation ID or not.


transactionConfig

protected TransactionConfig transactionConfig

resultsHandler

protected RouterResultsHandler resultsHandler

initialised

protected AtomicBoolean initialised

started

protected AtomicBoolean started
Constructor Detail

AbstractOutboundRouter

public AbstractOutboundRouter()
Method Detail

process

public MuleEvent process(MuleEvent event)
                  throws MuleException
Description copied from interface: MessageProcessor
Invokes the MessageProcessor.

Specified by:
process in interface MessageProcessor
Parameters:
event - MuleEvent to be processed
Returns:
optional response MuleEvent
Throws:
MuleException

route

protected abstract MuleEvent route(MuleEvent event)
                            throws MessagingException
Throws:
MessagingException

sendRequest

protected final MuleEvent sendRequest(MuleEvent routedEvent,
                                      MuleMessage message,
                                      MessageProcessor route,
                                      boolean awaitResponse)
                               throws MuleException
Throws:
MuleException

setMessageProperties

protected void setMessageProperties(FlowConstruct service,
                                    MuleMessage message,
                                    MessageProcessor route)

getRoutes

public List<MessageProcessor> getRoutes()
Description copied from interface: OutboundRouter
Gets a list of MessageProcessor instances associated with this router

Specified by:
getRoutes in interface OutboundRouter
Returns:
a list of MessageProcessor instances

setMessageProcessors

@Deprecated
public void setMessageProcessors(List<MessageProcessor> routes)
                          throws MuleException
Deprecated. 

Throws:
MuleException

setRoutes

public void setRoutes(List<MessageProcessor> routes)
               throws MuleException
Throws:
MuleException

addRoute

public void addRoute(MessageProcessor route)
              throws MuleException
Description copied from interface: MessageRouter
Adds a new message processor to the list of routes

Specified by:
addRoute in interface MessageRouter
Parameters:
route - new destination message processor
Throws:
MuleException

removeRoute

public void removeRoute(MessageProcessor route)
                 throws MuleException
Description copied from interface: MessageRouter
Removes a message processor from the list of routes

Specified by:
removeRoute in interface MessageRouter
Parameters:
route - destination message processor to remove
Throws:
MuleException

getReplyTo

public String getReplyTo()

setReplyTo

public void setReplyTo(String replyTo)
Description copied from interface: OutboundRouter
Sets the replyTo route for any outgoing messages. This will then be used by other Mule routers to send replies back for this message. If the underlying protocol supports replyTo messages, such as Jms, a Jms Destination will be attached to the outbound message

Specified by:
setReplyTo in interface OutboundRouter
Parameters:
replyTo - route string to use

getEnableCorrelation

public CorrelationMode getEnableCorrelation()

setEnableCorrelation

public void setEnableCorrelation(CorrelationMode enableCorrelation)

setEnableCorrelationAsString

public void setEnableCorrelationAsString(String enableCorrelation)

getTransactionConfig

public TransactionConfig getTransactionConfig()

setTransactionConfig

public void setTransactionConfig(TransactionConfig transactionConfig)
Specified by:
setTransactionConfig in interface OutboundRouter

isDynamicRoutes

public boolean isDynamicRoutes()
Description copied from interface: OutboundRouter
Determines whether this router supports dynamic route. i.e. routes that are not configured at design time. routes might be pulled from the message or payload.

Specified by:
isDynamicRoutes in interface OutboundRouter

getRoute

public MessageProcessor getRoute(String name)
Parameters:
name - the route identifier
Returns:
the route or null if the endpoint's Uri is not registered

getResultsHandler

public RouterResultsHandler getResultsHandler()

setResultsHandler

public void setResultsHandler(RouterResultsHandler resultsHandler)

sendRequestEvent

protected MuleEvent sendRequestEvent(MuleEvent routedEvent,
                                     MuleMessage message,
                                     MessageProcessor route,
                                     boolean awaitResponse)
                              throws MuleException
Send message event to destination.

Throws:
MuleException

createEventToRoute

protected MuleEvent createEventToRoute(MuleEvent routedEvent,
                                       MuleMessage message,
                                       MessageProcessor route)
Create a new event to be routed to the target MP


cloneMessage

protected MuleMessage cloneMessage(MuleMessage message)
Create a fresh copy of a message.


propagateMagicProperties

protected void propagateMagicProperties(MuleMessage in,
                                        MuleMessage out)
Propagates a number of internal system properties to handle correlation, session, etc. Note that in and out params can be the same message object when not dealing with replies.

See Also:
magicProperties

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
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 AbstractMuleObjectOwner<MessageProcessor>
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

dispose

public void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractMuleObjectOwner<MessageProcessor>

start

public void start()
           throws MuleException
Specified by:
start in interface Startable
Overrides:
start in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
MuleException

stop

public void stop()
          throws MuleException
Specified by:
stop in interface Stoppable
Overrides:
stop in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
MuleException

getMuleContext

public MuleContext getMuleContext()
Overrides:
getMuleContext in class AbstractMuleObjectOwner<MessageProcessor>

setRouterStatistics

public void setRouterStatistics(RouterStatistics stats)
Specified by:
setRouterStatistics in interface RouterStatisticsRecorder

getRouterStatistics

public RouterStatistics getRouterStatistics()

getOwnedMessageProcessors

protected List<MessageProcessor> getOwnedMessageProcessors()
Specified by:
getOwnedMessageProcessors in class AbstractMessageProcessorOwner


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