org.mule.routing.outbound
Class ExceptionBasedRouter

java.lang.Object
  extended by org.mule.routing.AbstractRouter
      extended by org.mule.routing.outbound.AbstractOutboundRouter
          extended by org.mule.routing.outbound.FilteringOutboundRouter
              extended by org.mule.routing.outbound.ExceptionBasedRouter
All Implemented Interfaces:
MuleContextAware, Disposable, Initialisable, OutboundRouter, Router

public class ExceptionBasedRouter
extends FilteringOutboundRouter

ExceptionBasedRouter Will send the current event to the first endpoint that doesn't throw an exception. If all attempted endpoints fail then an exception is thrown.

The router will override the sync/async mode of the endpoint and force the sync mode for all endpoints except the last one.


Field Summary
 
Fields inherited from class org.mule.routing.outbound.FilteringOutboundRouter
expressionManager
 
Fields inherited from class org.mule.routing.outbound.AbstractOutboundRouter
ENABLE_CORRELATION_ALWAYS, ENABLE_CORRELATION_IF_NOT_SET, ENABLE_CORRELATION_NEVER, enableCorrelation, endpoints, logger, messageInfoMapping, replyTo, resultsHandler, transactionConfig
 
Fields inherited from class org.mule.routing.AbstractRouter
muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
ExceptionBasedRouter()
           
 
Method Summary
protected  TransactionTemplate createTransactionTemplate(MuleSession session, ImmutableEndpoint endpoint)
           
protected  boolean exceptionPayloadAvailable(MuleMessage message)
           
 MuleMessage route(MuleMessage message, MuleSession session)
          This method is responsible for routing the Message via the MuleSession.
 
Methods inherited from class org.mule.routing.outbound.FilteringOutboundRouter
addEndpoint, getEndpoint, getFilter, getTransformers, initialise, isMatch, isRequiresNewMessage, isUseTemplates, setFilter, setTransformers, setUseTemplates
 
Methods inherited from class org.mule.routing.outbound.AbstractOutboundRouter
dispatch, getEnableCorrelation, getEndpoint, getEndpoints, getMessageInfoMapping, getReplyTo, getResultsHandler, getTransactionConfig, isDynamicEndpoints, removeEndpoint, send, setEnableCorrelation, setEnableCorrelationAsString, setEndpoints, setMessageInfoMapping, setMessageProperties, setReplyTo, setResultsHandler, setTransactionConfig
 
Methods inherited from class org.mule.routing.AbstractRouter
dispose, getMuleContext, getRouterStatistics, setMuleContext, setRouterStatistics
 
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.Router
getRouterStatistics, setRouterStatistics
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 

Constructor Detail

ExceptionBasedRouter

public ExceptionBasedRouter()
Method Detail

route

public MuleMessage route(MuleMessage message,
                         MuleSession session)
                  throws RoutingException
Description copied from interface: OutboundRouter
This method is responsible for routing the Message via the MuleSession. The logic for this method will change for each type of router depending on expected behaviour. For example, a MulticastingRouter might just iterate through the list of assoaciated endpoints sending the message. Another type of router such as the ExceptionBasedRouter will hit the first endpoint, if it fails try the second, and so on. Most router implementations will extends the FilteringOutboundRouter which implements all the common logic need for a router.

Specified by:
route in interface OutboundRouter
Overrides:
route in class FilteringOutboundRouter
Parameters:
message - the message to send via one or more endpoints on this router
session - the session used to actually send the event
Returns:
a result message if any from the invocation. If the synchronous flag is false a null result will always be returned.
Throws:
RoutingException
See Also:
FilteringOutboundRouter, ExceptionBasedRouter, MulticastingRouter

exceptionPayloadAvailable

protected boolean exceptionPayloadAvailable(MuleMessage message)
Parameters:
message - message to check
Returns:
true if there was an exception payload set

createTransactionTemplate

protected TransactionTemplate createTransactionTemplate(MuleSession session,
                                                        ImmutableEndpoint endpoint)
Overrides:
createTransactionTemplate in class AbstractOutboundRouter


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.