Object Store With Mule ESB

Object Store is used to store the object. Mule uses object store whenever it needs data persistent for later retrieval. Mule uses object store internally for various filters, routers and other processors that need to store state between messages. By default, object store connector not present in Mule palette. So you can install it from Anypoint exchange.

Object store connector can performed various operations like Contains, Dual store, Remove, Retrieve, Retrieve all keys, Retrieve and Store and Store.

  • Contains is used to verify if given key is present in object store.
  • Dual store stores a value using key and also stores a key using value.
  • Remove is to remove the respective key from object store.
  • Retrieve is used to retrieve an object from the object store and make it available in the specified property scope of a Mule Message.
  • Retrieve all keys will returns list of all keys present in object store.
  • Retrieve and Store is used to retrieve and store object in same operation.
  • Store is used to store the object in object store.

Object can be store in two ways

In-Memory is the default object store and object will be lost when runtime restarted.
Persistent is used file system to store the object and object will be not loose during runtime restart.

Storing Object In Object Store

Place the HTTP Listener in canvas region and configure it. Here we are expecting the query parameter and going to store that query parameter in object store.

Now, drag and drop object store into message processor and configure the object store.

  • Partition is name of the default In-Memory or persistent object store.[Required]
  • Object Store Reference specify the Object Store spring bean instance.[Optional]
  • Entry Ttl is Time-To-Live for stored values in milliseconds.  Max Entries” and “Expiration Interval” are mandatory for using this param. You must either provide all Entry TTL, Max Entries, and Expiration Interval, or none of them
  • Expiration interval specify the expiration check in milliseconds.
  • Max entries specify maximum number of entries.

Select the operation to Store for storing the object. Provide the Key and Value Reference (i.e. Key=EmployeeID, Value=#[message.inboundPrperties.’http.query.params.ID]).

Retrieving Object From Object Store

For retrieving the object from Object store, select the operation Retrieve and provide the key that you have used during store operation (i.e. Key=EmployeeID). In case, if key is not exists, it will throw exception.

Here is the video tutorial.

Now, you know how to store and retrieve object using Object Store Connector.

Add a Comment

Your email address will not be published. Required fields are marked *