Wednesday, July 13, 2011

MULE - Forwarding Catch All Strategy

Mule Version: 2.2.X

This catch-all strategy helps you to forward the message to an endpoint when none of the outbound routers match.

        <service name="StdioService">
            <inbound>
                <stdio:inbound-endpoint system="IN"
                    connector-ref="stdioInConnector" />
            </inbound>
            <outbound>
                <pass-through-router>
                    <vm:outbound-endpoint path="processInputIN" />
                </pass-through-router>
            </outbound>
        </service>

        <service name="ProcessInput">
            <inbound>
                <vm:inbound-endpoint path="processInputIN" />
            </inbound>
            <component class="org.mybusiness.components.ProcessInputComponent" />
            <outbound>
                <!-- Do not use pass through router while using catch-all-strategy, 
                       because that router will always work
                       as we don't have any criteria to match the endpoints.
                 -->
                <filtering-router>
                    <vm:outbound-endpoint path="computeLengthIN" />
                    <payload-type-filter
                        expectedType="java.lang.String" />
                </filtering-router>

                <!--
                    In your project you will be defining more specific
                    exceptions to be handled by different end-points
                -->
                <forwarding-catch-all-strategy>
                    <vm:outbound-endpoint path="processExceptionIN">
                        <exception-type-filter
                            expectedType="java.lang.Exception" />
                    </vm:outbound-endpoint>
                </forwarding-catch-all-strategy>
            </outbound>
        </service>

        <service name="ComputeLength">
            <inbound>
                <vm:inbound-endpoint path="computeLengthIN" />
            </inbound>
            <component
                class="org.mybusiness.components.ComputeLengthComponent" />
        </service>

        <service name="ProcessException">
            <inbound>
                <vm:inbound-endpoint path="processExceptionIN" />
            </inbound>
            <component
                class="org.mybusiness.components.ExceptionHandlerComponent" />
        </service>

No comments:

Post a Comment