1 of 1 people found this helpful
Before rules execution, the mapping expression is evaluated and the result is mapped into the rules session as a global. After rules execution, however, the global is not taken back out of the rules session and set back into the mapping expression. (The expression is only used in one direction - not both - and was intentional.) That's why naming a global mapping something like "output" doesn't really make sense.
There is a way, however, to do what you want. The "message" variable (representing org.switchyard.Message) is a global that will always be available to you in your DRL, and the content on it can be changed in your DRL itself, via get/setContent. If you modify the content via setContent, AND your rule service has a message ExchangePattern of IN_OUT, then the content you set in your DRL will be used as the outgoing content.
Hope this helps,
Thank you very much for the prompt reply, and I am sorry for this delayed response. Your answer was insightful indeed. I tried the setContent approach and it worked.
But, due to some design considerations at our end, what we finally ended up doing is to have a seperate data structure (i.e. a class) for each rule service, with its (i.e. service's) inputs/outputs defined as attributes of the class data structure. Thus, we used this single object for input as well as output (by setting message-exchange-pattern to IN_OUT).
Nevertheless, from your reply I got insights into the usage of message, exchange context etc with switchyard. Thank you very much.
I'm happy you found a solution. Having a single object to hold input/output is indeed a common solution; glad it works within your design.
Would you be so kind as to do a quick example of this? Im really struggling with how to get values out of a rule service.
That would be so appreciated!
Thanks and regards,