Class RouterMediator

  • All Implemented Interfaces:
    org.apache.synapse.aspects.AspectConfigurable, org.apache.synapse.ManagedLifecycle, org.apache.synapse.Mediator, org.apache.synapse.SynapseArtifact

    public class RouterMediator
    extends org.apache.synapse.mediators.AbstractMediator
    implements org.apache.synapse.ManagedLifecycle

    Routes the messages going through this mediator in to the specified target sequecne or to the taregt endpoint if the specified conditions under a particular route is matching. There can be several routes and one can specify to break after the first matching route using the breakRouter attirbute in the routes and hence the route order has some impact on the routings

    Normally message routing is redirecting the message, so this mediator also permits further mediation in this path where as the message is mediated using the roted path(s) by default, but it can be configured by the continueAfter attribute if required to continue further mediation of the path

    Individual routes are stored as Route objects keeping there conditions inside it with the routing targets as Target objects inside a particualr route and there is a linked list of Route per mediator.

    See Also:
    Route, Target, Mediator, AbstractMediator
    • Field Summary

      • Fields inherited from class org.apache.synapse.mediators.AbstractMediator

        log, trace, traceState
    • Constructor Summary

      Constructors 
      Constructor Description
      RouterMediator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRoute​(Route route)  
      void destroy()
      called when Router is destroyed
      List<Route> getRoutes()  
      void init​(org.apache.synapse.core.SynapseEnvironment synapseEnvironment)
      called on Router startup.
      boolean isContinueAfter()  
      boolean mediate​(org.apache.synapse.MessageContext synCtx)
      Routes the message depending on the specified set of routes if the routing condition is matching over the provided message.
      void setContinueAfter​(boolean continueAfter)  
      void setRoutes​(List<Route> routes)  
      • Methods inherited from class org.apache.synapse.mediators.AbstractMediator

        auditLog, auditWarn, configure, disableStatistics, disableTracing, divertMediationRoute, enableStatistics, enableTracing, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLastSequenceFaultHandler, getLog, getMediatorName, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAltering, isContentAware, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, isTracingEnabled, registerMediationFlowPoint, reportCloseStatistics, reportOpenStatistics, setBreakPoint, setCommentsList, setComponentStatisticsId, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldCaptureTracing, shouldTrace, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPoint
    • Constructor Detail

      • RouterMediator

        public RouterMediator()
    • Method Detail

      • mediate

        public boolean mediate​(org.apache.synapse.MessageContext synCtx)

        Routes the message depending on the specified set of routes if the routing condition is matching over the provided message. There can be a list of routers specified in to a particualr order, and these routes will be invoked to route the message in the specified order.

        If there is a matching route found over the message then the routing will occur and after this synchronized routing further mediation of the message through other routes specified after the matching route will be decided by the value of the breakRouter attribute of the route.

        By default this mediator will drop the message stopping further medaition along the current path and this also can be modified by using the continueAfter attribute of the mediator.

        Specified by:
        mediate in interface org.apache.synapse.Mediator
        Parameters:
        synCtx - message to be routed
        Returns:
        whether to continue further mediaiton or not as a boolean value
        See Also:
        Mediator.mediate(org.apache.synapse.MessageContext), Route.doRoute(org.apache.synapse.MessageContext, SynapseLog)
      • setRoutes

        public void setRoutes​(List<Route> routes)
      • addRoute

        public void addRoute​(Route route)
      • isContinueAfter

        public boolean isContinueAfter()
      • setContinueAfter

        public void setContinueAfter​(boolean continueAfter)
      • init

        public void init​(org.apache.synapse.core.SynapseEnvironment synapseEnvironment)
        called on Router startup. initializes inline sequences and endpoints
        Specified by:
        init in interface org.apache.synapse.ManagedLifecycle
        Parameters:
        synapseEnvironment -
      • destroy

        public void destroy()
        called when Router is destroyed
        Specified by:
        destroy in interface org.apache.synapse.ManagedLifecycle