0

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 ?

user4338724
  • 91
  • 2
  • 7

1 Answers1

1

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 _defaultUserObjectStore and Persistent option ref: https://docs.mulesoft.com/mule-user-guide/v/3.9/object-store-connector#persistingdata

Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81
  • I did tried the way mentioned in bushorn.com but did not worked. After your comment, I tried after restarting my Studio, and strangely its working now. I am assuming it cannot be already present, else I would have got ObjectAlreadyExist Exception, could be something I did wrongly previously. Thanks for your suggestion, its working now, will check this now on clustered Mule box. – user4338724 Oct 21 '17 at 22:07