Distributed cache using Mule 4.x Object Store V2

An Object Store Connector is one of the best connectors provided in the Mule run-time. It is a fully managed service that enables sharing of states in multi- clustered environments on CloudHub or on-prem Mule run-time without any risk of state loss during disaster events or application restarts. Object Store v2 allows applications store data and states across batch process and Mule components, from within a single application. Object Store v2 serve as the back-end for Mule3 and Mule4 object store access, by which write directly to the object store, use its REST API, write and read using Object Store connector.

Object Store V2 Offers

  • Object Store V2 keys can persist for 30 days unless updated, if a key is updated then expiry time reset to another 30 days.
  • Can store values up to 10 MB in size
  • No limit on total size of an Object Store
  • Mule Connector for Mule Application and for external application available as REST API.
  • Confirmable timeout to enable rollbacks.

Object Store Operations

  • Contains is used to verify if there is key given in object store
  • Remove is for removing the respective key from the object store
  • Retrieve is used for retrieving an object from object store and make it available in mule message
  • Retrieve all keys return list of all keys
  • A Store is used in storing an object in the object store

Example Use Case

The following App will store employee data containing employee identifier, first name, last name, and age in JSON format by using Object Store connector. Mule Application has two endpoints.

  1. /store
  2. /retrieve

Configuring ObjectStore

Dragging ObjectStore connector next to transform component we will configure it accordingly to below steps.

  • Click plus sign next to connector configuration field and add a new ObjectStore Element
  • Configure as shown below

Corresponding XML Configuration looks like

Royal Cyber with Anypoint Platform

Mule's object store is an appropriate way to store objects for future retrieval by key. If you want to upgrade your current object store to Object Store v2 or store data across batch processes and Mule components, in a single application, you can email us at info@royalcyber.com or visit www.royalcyber.com.

Leave a Reply