-
1. Re: Mapping global variables in Switchyard Rules Service
dward Jul 30, 2012 10:11 AM (in response to avadhut.sardeshmukh)1 of 1 people found this helpfulHi Avadhut,
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,
David
-
2. Re: Mapping global variables in Switchyard Rules Service
avadhut.sardeshmukh Aug 8, 2012 6:59 AM (in response to dward)Hello David
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.
-Avadhut.
-
3. Re: Mapping global variables in Switchyard Rules Service
dward Aug 8, 2012 9:37 AM (in response to avadhut.sardeshmukh)Avadhut,
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.
David
-
4. Re: Mapping global variables in Switchyard Rules Service
magick93 Jan 3, 2013 9:07 PM (in response to dward)Hi David
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,
Anton
-
5. Re: Mapping global variables in Switchyard Rules Service
dward Jan 4, 2013 10:56 AM (in response to magick93)Anton, I've responded over here. Let's keep the conversation in one place, please?