Nav

To Use Object Store

Object Store v2 lets you share data and states across batch processes, Mule components, within a single application. You can also use object store as a distributed object store for advanced use cases such as API caching and API rate limiting.

Notes:

  • To use Object Store v2, you must have an entitlement for this product. Contact your MuleSoft Sales representative for more information.

  • Key values cannot contain a forward slash character (/).

Components

Anypoint Object Store 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.

  • REST 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.

To Install the Object Store Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for this connector and click Install.

  4. Follow the prompts to install the connector.

When an updated version of a connector is released, Anypoint Studio displays the Updates Available popup in the bottom right corner of Studio. Click the popup and install the new version.

To Use Object Store Connector in an Application

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

  2. Create a simple flow such as the following:

    Building Block

    Parameters

    HTTP connector

    Host = All interfaces [0.0.0.0] (Default)
    Port = 8081
    Path = /store
    Allowed Methods = POST

    Object to String

    No settings (use defaults)

    JSON to Object

    Return Class = java.util.Map

    Object Store connector

    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 a version with OBJECT-STORE in the runtime name.

    • 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.

When you choose a Runtime Version containing OBJECT-STORE in the version name, 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 default time to live (TTL) value is 14 days (1209600 seconds) and the maximum TTL is 30 days (2592000 seconds).

  4. Click the Object Store name. You can click a key name to view its value.

  5. You can delete keys by clicking the Key down arrow symbol:

    osv2-delete-keys