Mule's object store is a convenient way to store objects for later retrieval by key, essentially a key-value store. By default, this is in-memory, but it can also be easily changed to persist to file.
Below is the list of available operations supported by the Object store. The object store connector can perform various operations like Contains, Dual store, Remove, Retrieve, Retrieve all keys, Retrieve, and Store and Store.
1) All Keys
Returns a list of all the keys in the object store. It returns the java.util.List<String> with all the keys in the store.
This operation Checks whether the object store contains the given key or not, it returns true if the object store contains the key, or false if it doesn't.
<objectstore:contains config-ref="ObjectStore__Configuration" key="member_id" doc:name="ObjectStore"/>
Remove the object from the respective key. It returns the object that was previously stored for the given key. If the key does not exist and
ignoreNotExists is true the operation will return a null object.
<objectstore:remove config-ref="ObjectStore__Configuration" key="member_id" doc:name="ObjectStore"/>
Retrieve an object from the object store and make it available in the specified property scope of a Mule Message. It returns the object associated with the given key. If no object for the given key was found, this method throws an
<objectstore:retrieve config-ref="ObjectStore__Configuration" key="#[message.inboundProperties.'http.query.params'.id]" doc:name="Retrieve Employee"/>
5) Retrieve store
This is when Retrieve and Store are in the same operation.
Stores an object in the object store. This allows an option to indicate if the key would be overwritten or not.
Note: If the method is not supported
java.lang.UnsupportedOperationException is thrown.
In the Next Post…
That’s it! We have just understood the basics of object store and different operations supported by Object store. In our next post, Working With Object Store in Mule, Part 3, we’ll do some hands-on work in Anypoint Studio.
Hope this helps, thanks!