1 Reply Latest reply on Jul 11, 2012 9:02 AM by kcbabo

    Setting headers on messages passed to the Invoker

    edevera

      I am trying to create an integration test based on the SwitchYardRunner + SwitchYardTestKit but I am having problems regarding the use of headers.

       

      I use a CamelRouteBuilder component in order to implement the routing logic of the message. In this CamelRouteBuilder I have conditions such as

       

      .when(header("operation").isEqualTo("save"))
      

       

      When I try to test this code, I can't because I don't see a way to set header properties when using the Invoker object provided by Switchyard. Is there a way to do so? If not, is there a reason why?

       

      Thanks!

        • 1. Re: Setting headers on messages passed to the Invoker
          kcbabo

          There is not a way to do this with the current Invoker sendInOnly() and sendInOut() methods.  You can, however, use the Invoker.createExchange() method to create a SY exchange and then grab the Context from there.  Properties you set on the context should be available in the Camel route/message via the Camel message composer, IINM. 

           

          We could make it easier to specify a bag of properties on the call to sendInOnly and sendInOut.  Under the covers, the properties would be set on the underlying exchange before it's sent.  Of course, this begs the question of whether the context properties should be available upon return (e.g. you set a header for the return message in your service and want to assert it's set). 


          I would say document the requirements you have in a JIRA and we can take it from there.  I can see a number of ways to make this easier and more powerful than what we have today.