Question

I want to ask about how to passing value between sequences in WSO2 ESB.
For example :
I have 2 sequences :
"getNumber" sequence that called a class that return a number.
"printNumber" sequence which print a sting and has a property "number"

So I want to call the first sequence that return a number than I want to pass that number to the printNumber sequence. How can i pass the value here?

Thanks for your help :)

Was it helpful?

Solution

You can use the Property Mediator [1] to achieve the above. So what you have to do is, in the first sequence set this property (let's say 'numberToPrint') and retrieve it in the second sequence as described in [1]. If the first sequence is calling the class though a class mediator [2], you can set the property inside the class itself (messageContext.setProperty(key, value)).

[1] http://docs.wso2.org/wiki/display/ESB460/Property+Mediator

[2] http://docs.wso2.org/wiki/display/ESB460/Class+Mediator

OTHER TIPS

Here is an example how I was able to pass values from sequence to sequence using property mediator.

I have an XML like so that is being passed into my proxy.

<data>
<AccountID>124</AccountID>
</data>

My Property Mediator will set the data to the Property I defined below.

 <property name="AccountID" expression="//data/AccountID/text()" scope="default" type="STRING" />

Now I can access the property in other Sequences as such.

 <property name="******Account-ID*****" expression="$ctx:AccountID" />

It all depends on the scope in which you set the property in order for it to be accessed by other sequences. By deafult it is set at Synapse Message Context.

You can access the value of the property by get-property('NAME_OF_PRO'). For example let's say you have set a property named 'number' in the first sequence. Now in the second sequence you can log the value of the property as follows.

<log level="custom">
    <property name="Value_of_number" expression="get-property('number')"/>
</log>

Note: In the first sequence you have to set the property's scope as default (scope="default") which will make the property available in the Synapse message context.

This [1] will help you more on your requirement.

[1] wso2 esb Class Mediator

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top