I am not able to read value of key that is stored in Object Store from App1.
I have 2 application, App1 which stores the value of variable (say 'name,) to some value (say 'abc'). From App2, I wanted to retrieve the value of the key ('name' in our case), but it always fails with the org.mule.api.store.ObjectDoesNotExistException.
If both of the flow is on the same app, it works, but this is not the expected behaviour.
Both the applications are running on the same runtime, hence it should be able to retrieve the value.
Below is my code for App1
<flow name="objectstore1Flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/retrieve" allowedMethods="GET" doc:name="HTTP"/>
<set-variable value="abc" variableName="name" doc:name="Variable" />
<objectstore:store config-ref="ObjectStore__Connector" key="name" value-ref="#[flowVars.name]" doc:name="ObjectStore" />
</flow>
Code for App2
<flow name="objectstore2Flow">
<http:listener config-ref="gcc-httpDomainListenerConfig" path="/store2" allowedMethods="GET" doc:name="HTTP"/>
<objectstore:retrieve config-ref="ObjectStore__Connector" key="name" doc:name="ObjectStore" targetScope="INVOCATION"/>
<logger message="Value of name from cache is : #[payload]" level="INFO" doc:name="Logger"/>
</flow>
Object Store configuration for both the application is :
<objectstore:config name="ObjectStore__Connector" partition="name_value" doc:name="ObjectStore: Connector"/>
Can some one guide me, where I am going wrong ?
The main reason is both the application are independent to each other and using its own memory store to save the data.
So, when your app1 store its data, it store on its own in-memory which is not available for app2 as it is using its own in-memory independently.
Both apps are referring to its own Object Store config.
The solution to share Object Store will be a domain project where you will be defining a single Object store in the domain and that will be shared among all its child applications like app1, app2, app3 etc
Follow the step here how you can do it :- http://bushorn.com/dealing-with-store-the-object-store/
For Persisting ObjectStore use
_defaultUserObjectStoreand Persistent option ref: https://docs.mulesoft.com/mule-user-guide/v/3.9/object-store-connector#persistingdata