from my understanding SwitchYard should never touch (or better) remove custom message headers while my invocation is processed.
However I have a service implementation with a camel route, that invokes a drools rule through a reference to a rules component.
Before the reference invocation I set a message scoped property (through Camel DSL .setHeader()), which is used in the rules component, but also needed after the reference invocation.
Interestingly the message property is lost after the reference invocation.
From the code  I see, that a new message is created, BUT only mapped headers are copied back.
This lead me to this workaround:
<rules:operation name="process" type="EXECUTE"> <rules:globals> <!-- 1 Include required property --> <rules:global from="context['myProperty']" to="myPropertyGlobal"/> <!-- 2 Include all headers --> <rules:global from="message.headers" to="headers"/> </rules:globals> <rules:inputs> <rules:input from="message.content"/> </rules:inputs> <rules:outputs> <rules:output from="Result" to="message.content"/> <!-- 3 Set back all headers --> <rules:output from="headers" to="message.headers"/> <!-- 4 Remove problematic headers --> <rules:output from="null" to="message.headers['messageId']"/> <rules:output from="null" to="message.headers['org.switchyard.bus.camel.messageSent']"/> <!-- 5 Set changes property back --> <rules:output from="myPropertyGlobal" to="message.headers['myProperty']"/> </rules:outputs> </rules:operation>
This works, but from my understanding it should only be necessary to specify changed properties and not to specify everything here.
Furthermore I had to add implementation specifc mappings to avoid problems in the message handling (messageSent property).
Wouldn't it make sense to include a mapping like it is implemented in org.switchyard.component.camel.ExchangeMapper after the message creation in the RulesExchangeHandler?
In my opinion the mappings 1 and 5 should be enough and 2 to 4 should not be necessary.