Determine the invoked contract's operation in Camel Route

Version 1

    When getting started with Camel Route implementation. I have encountered a problem: If the contract of the component has multiple methods, I have no idea to find what method is invoked. Fortunately, thank Jorge Morales for the great answer. Additionally, I found the a enhancement was done for this purpose [SWITCHYARD-872] Populate Camel messages with Switchyard metadata - JBoss Issue Tracker .

    So, in order to determine which is the invoked operation we could have the routing like this:

    <camel:implementation.camel>
        <route xmlns="http://camel.apache.org/schema/spring" id="CamelMathRoute">
            <to uri="log:test?showAll=true" />
            <choice>
                <when>
                    <simple>${header.org.switchyard.operationName} == 'cos'</simple>
                    <to uri="switchyard://MathCos" />
                </when>
                <when>
                    <simple>${header.org.switchyard.operationName} == 'abs'</simple>
                    <to uri="switchyard://MathAbs" />
                </when>
                <otherwise>
                    <to uri="mock:unknown" />
                </otherwise>
            </choice>
            <to uri="switchyard://MathAll" />
        </route>
    </camel:implementation.camel>
    

     

    Hope this help!