I have the following doubt related how to store something like a global property in WSO2 ESB. I try to explain my situation.
I have a message processor in which is defined a sequence that is executed every second, something like this:
<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" messageStore="glisMessageStore" name="glisMessageProcessor" targetEndpoint="glisEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="client.retry.interval">100</parameter>
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="member.count">1</parameter>
<parameter name="message.processor.reply.sequence">glisResponseSequence</parameter>
<parameter name="max.delivery.drop">Disabled</parameter>
<parameter name="interval">10</parameter>
<parameter name="is.active">true</parameter>
</messageProcessor>
Into this glisResponseSequence.xml I perform a call to an external web service. In this sequence I have to do something that is a little "weird".
I have to do something like explained in the following sequence schematisation:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="transferProcessorSequence" onError="transferFromErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full"/>
..................................................................
..................................................................
..................................................................
1) RETRIEVE THE VALUE FROM A "GLOBAL PROPERTY" NAMED sleepingTime
2) IF sleepingTime != NULL PERFORM A JAVASCRIPT THAT USE THIS VALUE
3) CALL EXTERNAL WEB SERVICE:
<call>
<endpoint key="transferFromGLISAPI"/>
</call>
4) SET THE NEW VALUE OF THE sleepingTime "GLOBAL PROPERTY" (it is retrieved from the response header)
..................................................................
..................................................................
..................................................................
</sequence>
So, in my sequence I have a call mediator. After this call mediator I have to set something like a global property with a value retrieved from the response header (obtain this value is not a problem for me). The value of this global property will be used again before my call mediator when the message processor will execute again this sequence.
How can I do it? My doubt are:
1) Where have I to define this global property? I think that I have to declare it outside this glisResponseSequence.xml (the sequence executed by the message processor). Can I declare it into another sequence?
2) What is the correct scope for this global property?
It is very important to me store a value that I obtain after that the call mediator perform the http request to the external web service and use it again before the next call (when the glisResponseSequence.xml sequence is executed again by the message processor). Can I do it? Another solution could be store this date on the database but, if it is possibile, I prefer use something like a global property.