I have a mule flow which is a SOAP web service client (Mule Flow - A). This client call will be executed every 30 minutes to retrieve a unique session key from a 3rd party. I have other mule flows (running as separate mule applications) which need to refer this session variable in their flows. My question is - Is there a way to persist the session key retrieved by Mule Flow A in the mule server memory, so that other mule applications can access it during run-time? It is possible to save the data somewhere in a file or a database and retrieve it, but I would like to check whether this can be done otherwise before concluding with a solution.
Thanks!
Updated Sample Mule Flow for Shared Object Store:
Flow 1:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd">
<spring:beans>
<spring:bean id="myListableObjectStore" class="org.mule.util.store.SimpleMemoryObjectStore"/>
</spring:beans>
<objectstore:config name="ObjectStore" objectStore-ref="myListableObjectStore" doc:name="ObjectStore"/>
<flow name="objectstoreFlow1" doc:name="objectstoreFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP"/>
<message-filter doc:name="Filter favicon">
<not-filter>
<wildcard-filter pattern="/favicon.ico" caseSensitive="true"/>
</not-filter>
</message-filter>
<logger message="#[message.InboundProperties.key]" level="INFO" doc:name="Logger"/>
<objectstore:store config-ref="ObjectStore" key="#[message.inboundProperties.key]" value-ref="#[message.inboundProperties.value]" doc:name="ObjectStore"/>
</flow>
</mule>
Mule Flow 2 - To retrieve the value
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd">
<spring:beans>
<spring:bean id="myListableObjectStore" class="org.mule.util.store.SimpleMemoryObjectStore"/>
</spring:beans>
<objectstore:config name="ObjectStore" objectStore-ref="myListableObjectStore" doc:name="ObjectStore"/>
<flow name="MemoryTest2Flow1" doc:name="MemoryTest2Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" doc:name="HTTP"/>
<message-filter doc:name="Filter favicon">
<not-filter>
<wildcard-filter pattern="/favicon.ico" caseSensitive="true"/>
</not-filter>
</message-filter>
<objectstore:retrieve config-ref="ObjectStore" key="#[message.inboundProperties.key]" doc:name="ObjectStore"/>
<logger level="ERROR" doc:name="Logger"/>
</flow>
</mule>
Will I be able to retrieve the stored object in the first flow as part of the second mule flow using the same key?