1 Reply Latest reply on Jul 11, 2014 8:24 AM by Tomohisa igarashi

    MessageComposer.compose not called on Outbound Camel Binding

    Erhard Siegl Novice

      Hi,

       

      I try to use a Camel binding with custom message composer on an in-out exchange. The decompose is called, but the compose not.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <sy:switchyard xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:camel_1="urn:switchyard-component-camel-core:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sy="urn:switchyard-config:switchyard:1.1" name="fsw-script-binding" targetNamespace="urn:at.objectbay.examples:fsw-script-binding:1.0">

        <sca:composite name="fsw-script-binding" targetNamespace="urn:at.objectbay.examples:fsw-script-binding:1.0">

          <sca:component name="CamelServiceRoute">

            <camel:implementation.camel>

              <camel:java class="at.objectbay.examples.fsw_script_binding.CamelServiceRoute"/>

            </camel:implementation.camel>

            <sca:service name="OrderingInt">

              <sca:interface.java interface="at.objectbay.examples.fsw_script_binding.Ordering"/>

            </sca:service>

            <sca:reference name="Ordering">

              <sca:interface.java interface="at.objectbay.examples.fsw_script_binding.Ordering"/>

            </sca:reference>

          </sca:component>

          <sca:reference name="Ordering" multiplicity="0..1" promote="CamelServiceRoute/Ordering">

            <sca:interface.java interface="at.objectbay.examples.fsw_script_binding.Ordering"/>

            <camel_1:binding.uri name="execScript" configURI="exec://echo">

              <camel_1:messageComposer class="at.objectbay.examples.fsw_script_binding.CamelExecComposer"/>

            </camel_1:binding.uri>

          </sca:reference>

        </sca:composite>

      </sy:switchyard>

       

      public class CamelExecComposer extends BaseMessageComposer<CamelBindingData>

        implements MessageComposer<CamelBindingData> {

       

        @Override

        public Message compose(CamelBindingData source, Exchange exchange)

        throws Exception {

        getContextMapper().mapFrom(source, exchange.getContext());

       

              System.out.println("CamelExchangeComposer compose()");

      ...

        return message;

        }

       

       

        @Override

        public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {

                getContextMapper().mapTo(exchange.getContext(), target);

        

                System.out.println("CamelExchangeComposer decompose()");

                org.apache.camel.Message targetMessage = target.getMessage();

        

                List<String> args = new ArrayList<String>();

                args.add("First Argument");

                args.add("Second Argument");

                targetMessage.setHeader(ExecBinding.EXEC_COMMAND_ARGS, args);

               

                targetMessage.setBody(exchange.getMessage().getContent());

                return target;

            }

       

      The Unit-Test works:

        public void testProcess() throws Exception {

       

        String message = "Hello";

        String res = service.operation("process").sendInOut(message).getContent(String.class);

       

        assertEquals("Arguments from Message Composer", "First Argument Second Argument\n", res);

        }

       

      But the System.out from compose() does not show in the output.

      I also looked around in the source code a little (org.switchyard.component.camel.common.handler.OutboundHandler) but didn't find the call.

       

      Is this a bug or some misinterpretation on my side?

       

      I can upload the sample project if needed.

       

      Thanx for any help

      Erhard