Nav

To Use Object Store

Object Store v2 (OSv2) lets you share data and states across Mule runtime workers within a single application.

OSv2 is enabled by default in the Anypoint Platform EU Control Plane and in Mule 4.

In Mule 3, enable OSv2 from Anypoint Platform > Runtime Manager for each application you want to access OSv2.

Components

OSv2 consists of these components:

  • Object Store Connector

    Use with Anypoint Studio to construct flows to write to and read from the object store. You can install the Object Store connector using Anypoint Exchange from within Anypoint Studio. After installed, search Studio for "objectstore". The Object Store connector works with both Object Store version 1 and version 2. Use Studio to create an application that you deploy to Runtime Manager where the application runs and serves requests to read to and write from the object store.

    Note: The Object Store connector’s Object Store Reference field (objectStore-ref element in XML) must be set to _defaultUserObjectStore for data to appear in Object Store v2.

  • REST API

    The OSv2 API lets you create and delete objects, set TTL (time to live) for objects, and set usage limits.

  • Runtime Manager

    When you enable object store, the Runtime Manager > Application Data setting changes its label to Object Store. From the object store interface, you can administer objects and their values in the object store. The interface also lets you delete object store objects.

About Protecting Object Store Data

Object Store v2 uses TLS for secure transport. Data at rest is stored using FIPS 140-2 compliant encryption standards. If you require a higher level of security, we recommend that you encrypt sensitive data before writing it to the Object Store.

To Install the Object Store Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio task bar.

  2. Click Login in Anypoint Exchange.

  3. Search for the "objectstore connector", choose the version of the connector for Mule 3 or Mule 4, and click Install.

  4. Follow the prompts to install the connector.

To Use Object Store Connector in an Application

Note: The information that follows applies only to Mule 3.

  1. In Anypoint Studio, click File > New > Mule Project.

  2. Create a simple flow such as the following:

    Building Block

    Parameters

    HTTP connector

    Click Green Plus sign
    Host = All interfaces [0.0.0.0] (Default)
    Port = 8081
    Click OK
    Path = /store
    Allowed Methods = POST

    Object to String

    No settings (use defaults)

    JSON to Object

    Return Class = java.util.Map

    Object Store connector

    Click Green Plus sign.
    Set the Partition field.
    Set the Object Store Reference field to _defaultUserObjectStore. This is mandatory for data to be stored in OSv2.
    Click OK.
    Set the Operation = Store
    Key = #[payload.key]
    Value Reference = #[payload.value]

    Set Payload

    Settings = KEY: #[payload.key] AND VALUE: #[payload.value] WERE SAVED OK

    When done, the flow appears as:

    osv2-studio-flow

  3. Save the application. Test run the application so you know it works. Right-click the canvas and click Run project <name>. If the application starts successfully, you can stop it. Right-click the canvas and click Stop project <name>.

  4. Right-click your application’s name in Anypoint Studio’s Package Explorer and click Anypoint Platform > Deploy to Cloud.

  5. At the User login window, specify your Anypoint Platform username and password, and click Sign In. If you don’t have an Anypoint Platform login, click Sign Up.

  6. In Runtime Manager:

    • Give the application a name. Each name is unique and becomes the URL under which your application is stored in Runtime Manager. The URL is in the form <application_name>.cloudhub.io. Ensure the application name gets a green checkmark for proper naming and being unique.

    • Set the Runtime version to Mule 3.8.5 and later, or to any Mule 4.x version.

    • Click the Use Object Store v2 checkbox.

  7. After configuring your application, click Deploy Application.

  8. Runtime Manager prompts you to ensure you want to make this choice.

  9. Start your application.

The Application Data label in the Runtime Manager navigation bar on the left side of the screen changes to Object Store.

To Send Data to an Object Store

From a command line prompt, use a utility to send JSON data to your Mule application. This can be a command such as curl, Postman, or a browser extension. For Windows, you can use Postman, curl, or cygwin.

For example:

curl -X POST -H "Content-Type: application/json" -d '{ "key": "TestKey01", "value": "This is an object store test" }' "http://<application_name>.cloudhub.io/store"

Change <application_name> to the name you chose when you deployed your application. Each time you submit this command, change the key’s name so that each key is unique.

To View Data in an Object Store

To view data in the Object Store:

  1. Log into Anypoint Platform and click Runtime Manager.

  2. Click the name of your application to view the application’s dashboard.

  3. Click Object Store from the left navigation bar:

    osv2-in-nav-bar

    The Object Store user interface appears as follows:

    osv2-ui

    • The default Object Store name is DEFAULT_USER_STORE.

    • The columns show the Object Store name, partition name, key, and key data. The partition groups object store keys.

  4. Click the Object Store name, partition name, and key to view its value.

  5. To delete a key, hover over a key name, and click the trash can icon. Similarly, you can delete a partition or the store itself by hovering and clicking the trash can icon.

Note: Object Store provides persistent storage of objects with a time to live (TTL) of 30 days. See How long can data persist in OSv2?.