Contact Free trial Login

Store Application Data Using Object Stores

An object store is a facility for storing objects in or across Mule applications. Mule runtime engine (Mule) uses object stores to persist data for eventual retrieval. Internally, Mule uses object stores in various filters, routers, and other message processors that need to store states between messages.

Object stores are available in all deployment targets. If you deploy your application to CloudHub, you can also use Object Store V2.

Use Cases

You can configure a custom object store to use in the following scenarios:

  • When configuring an Idempotent Message Validator, to store the unique IDs in the specified object store.

  • When configuring a Redelivery policy in a listener (HTTP, File, JMS, VM, Socket), to store the redelivery count in the specified object store.

  • When configuring a Cache scope that uses a custom caching strategy, to store the cached data in the specified object store.

  • When a custom component uses an object store to persist information.

  • When storing or retrieving information from a Mule flow, by using Anypoint Connector for Object Store (Object Store Connector).

Object Store Configuration

By default, each Mule application has an object store that is persistent and is always available to the app. You can also create custom object stores, which can be persistent or in-memory.

You can configure an object store as a global element, to be accessible for any component in your app, or configure a custom object store for a specific component that supports its usage.

Configure a Global Object Store

To configure a global object store that can be referenced by other components in your application, follow these steps in Anypoint Studio:

  1. Open the Global Elements tab.

  2. Click Create.

  3. Select Component configurations > Object Store.

  4. Complete the required configuration attributes and click OK.
    global object store

Alternatively, you can create a global object store by including the following code as a top-level element in your application XML:

<os:object-store name="myObjectStore"
   entryTtl="1"
   entryTtlUnit="HOURS"
   maxEntries="100"
   persistent="true"
   expirationInterval="30"
   expirationIntervalUnit="MINUTES" />

Configure each attribute with the desired value.
See Object Store Reference for a definition of each XML attribute.

Configure an Object Store for a Specific Component

You can configure an object store that is available only for a specific component. For example, to configure an object store for an Idempotent Message Validator, follow these steps in Anypoint Studio:

  1. Open the Idempotent Message Validator properties.

  2. In Object Store, select Edit Inline.

  3. Complete the required configuration attributes and click OK.
    Inline object store

Alternatively, you can create the object store by including the object store configuration inside the component element in the XML configuration file:

<idempotent-message-validator doc:name="Idempotent Message Validator" >
  <os:private-object-store
    maxEntries="20"
    entryTtl="20"
    entryTtlUnit="MILLISECONDS"
    expirationInterval="20"
    expirationIntervalUnit="MILLISECONDS"
    config-ref="ObjectStore_Config" />
</idempotent-message-validator>

Manage Data Using the Object Store Connector

The Object Store connector enables you to perform different operations to interact with the object stores in your Mule application. Example operations include Store, Retrieve and Remove.

See the Object Store Connector documentation for details about available operations and configuration examples.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub