How to use Account Store, Flow Store, and Memory Store
IBM® webMethods Integration allows you to store key-value pairs and fetch them when required during a workflow execution. IBM webMethods Integration provides this functionality with three data store actions, namely, Account Store, Flow Store, and Memory Store. Though all the three data store actions seem to perform the same task, there are certain key differences in their features that make them ideal for different scenarios. Let us now know exactly what each of these actions do and understand how to use them.
How to Use Account Store
The Account Store action lets you store one or more key-value pairs with a global scope and retrieve them during any workflow execution. This means that, each key-value pair you store using the Account Store action can be retrieved while working with any workflow of any project in your tenant. Let us understand this with the help of an example.
Let's say we have two different projects: Default and Recipes. In Default, we will create a workflow to set a key-value pair. Next, we will retrieve the value of this key using the workflow created in the Recipe project.
Set Key-Value Pairs with Account Store
Add the Account Store action on canvas and connect it to the Start and Stop. icons. Then configure the Account Store action.
Double-click the Account Store action icon, optionally provide a suitable name for this action, and then click Next. This will take you to the Account Store action configuration screen. Configure this action as per the instructions given below:
- Account Store: As we want to set a key-value pair, select Set from the drop-down menu.
- Key (mandatory): Provide a suitable name for the key you want to set.
- Value: Enter the value you want to assign to the specified key.
You can set as many key-value pairs as you want by clicking on the + button. Once you have entered all the required details, click Next, optionally Test the action and then click Done to return to the canvas.
With this, you have successfully created and stored the key-value pairs. Once you add the key-value pairs, you can fetch them anytime in future. Let's now understand how to retrieve values of the stored keys.
Retrieve Values of Stored Keys from Account Store
We will now understand how to retrieve the value of stored keys with Account Store action. For this, we will create a workflow in the project named Recipes with Account Store action to retrieve the value of a stored key and then post the details on a Slack channel.
Add actions/connectors to canvas.
Add Account Store action and Slack connector to canvas and connect them.
After the actions are added to the canvas, the next step is to configure these actions.
Configure the Account Store action.
Double-click the Account Store action icon, optionally provide a suitable name for this action, and then click Next*. This will take you to the Account Store action configuration screen. Configure this action as per the following instructions:
Account Store: As we want to get the value for a stored key, select Get from the drop-down list.
Key (mandatory): Provide the name of the stored key, the value you want to retrieve. You can fetch values of multiple keys by clicking the + button.
Once you have entered all the required details, click Next, optionally Test the action and then click Done to return to the canvas.
Next, configure the Slack - Post New Message action as you would normally do to post what we retrieved earlier on the specified Slack channel.
Once this is done, Save the workflow. Now when you Run the workflow, IBM webMethods Integration will automatically fetch the value of the key and post it on the specified Slack channel.
Delete the stored Key-Value pair from Account Store
If you want to delete a stored key-value pair from Account store, select Delete from the drop-down list, specify the name of the key you want to delete, and then click Next.
Doing this will successfully delete the key and its associated value from the Account Store action.
How to Use Flow Store
The Flow Store action allows you to store one or more key-value pairs and retrieve them when required from within the same workflow of the project. This means the keys stored inside a workflow using Flow Store can be retrieved on all subsequent executions of that particular workflow, but they cannot be retrieved outside of that workflow.
Let's understand how to set key-value pairs and retrieve their values using the Flow Store action with the help of an example.
Set Key-Value Pairs with Flow Store
Add Flow Store action on the canvas and connect to the Start and Stop icons:
Now that the action is added to the canvas, the next step is to configure the Flow Store action.
Double-click the Flow Store action icon, optionally provide a suitable name for this action, and then click Next. This will take you to the Flow Store action configuration screen. Configure this action as per the following instructions:
Flow Store: As we want to set a key-value pair, select Set from the drop-down list.
Key (mandatory): Provide a suitable name for the key you want to set.
Value: Enter the value you want to assign to the specified key. You can set as many key-value pairs as you want by clicking the + button.
Once you have entered all the required details, click Next, optionally Test the action, and then click Done to return to the canvas.
With this, you have successfully created and stored the key-value pair (s). Once you have created and stored the key-value pairs, you can retrieve them from the same workflow. Let's now understand how to get or retrieve values of the stored keys.
Retrieve Values of Stored Keys with Flow Store
To get or retrieve values of the stored keys, we will have to add the Flow Store action in the same workflow where we had stored and then post its details on a Slack channel.
Add actions/connectors to the canvas. Add Flow Store and Slack action on the canvas and connect to the Start and Stop icons.
Now that the actions are added, the next step is to configure these actions.
Double-click the Flow store action icon, optionally provide a suitable name for this action, and then click Next. This will take you to the Flow Store action configuration screen. Configure this action as per the following instructions:
Flow Store: As we want to get the value for a stored key, select Get from the drop-down list.
Key (mandatory): Provide the name of the stored key, the value you want to retrieve. You can fetch the value of multiple stored keys by clicking the + button.
Once you have entered all the required details, click Next, optionally Test the action and then click Done to return to the canvas.
Next, configure the Slack - Post New Message action as you would normally do to post the key value details we retrieved earlier on the specified Slack channel.
Once this is done, Save the workflow. Now when you Run the workflow, IBM webMethods Integration will automatically fetch the value of the key and post it on the specified Slack channel.
Delete the stored Key-Value pair from Flow Store
IBM webMethods Integration allows you to delete stored key-value pairs from the Flow Store action.
If you want to delete a stored key-value pair from the Flow store, select Delete from the drop-down list, specify the name of the key you want to delete, and then click Next.
Doing this will successfully delete the key and its associated value from the Flow Store action.
How to Use Memory Store
The Memory Store action lets you store and retrieve one or more key-value pairs which is limited to only single workflow run. This means that the keys stored inside a workflow using Memory Store remain active for only one execution. On the subsequent execution of the same workflow, you cannot retrieve the keys stored in the previous execution. So if you want to set key-value pairs and get the values of stored keys in the same workflow, you will have to add two Memory Store actions in the same workflow.
Let's now understand how to set key-value pairs and retrieve the values using the Memory Store action with the help of an example. Let's say we have a workflow that sets a key-value pair, gets the values for the stored key, and posts the value details on the specified Slack channel.
Set Key-Value Pairs and Retrieve Values of Stored Keys with Memory Store
Add actions/connectors to canvas.
Add two Memory Store actions, one for setting key-value pairs and another one for retrieving values of stored keys to the canvas, along with the Slack connector. Connect these actions and the connector to the Start and Stop icons.
Configure the Memory Store action for setting Key-Value Pairs.
Double-click the first Memory store action icon to set key-value pairs. Optionally provide a suitable name for this action, and then click Next. This will take you to the Memory Store action configuration screen. Configure this action as per the following instructions:
Memory Store: As we want to set a key-value pair, select Set from the drop-down list.
Key (mandatory): Provide a suitable name for the key you want to set.
Value: Enter the value you want to assign to the specified key. You can set as many key-value pairs as you want by clicking the + button.
After you have entered all the required details, click Next, optionally Test the action, and then click Done to return to the canvas. With this, you have successfully created and stored the key-value pairs.
Configure the Memory Store action for retrieving values for stored keys
Double-click the second Memory Store action icon to get value details of the stored key. Optionally provide a suitable name for this action, and then click Next. This will take you to the Memory Store action configuration screen. Configure this action as per the following instructions:
-
Memory Store: As we want to get the value for a stored key, select Get from the drop-down list.
-
Key (mandatory): Provide a suitable name of the stored key, the value you want to retrieve. You can retrieve the value of multiple stored keys by clicking the + button.
Once this is done, click Next, optionally Test the action, and then click Done to return to the canvas.
Next, configure the Slack - Post New Message action as you would normally do, to post the key value details we retrieved earlier on the specified Slack channel.
Once this is done, Save the workflow. Now, when you Run the workflow, you will get the value details on the specified Slack channel. If you try to execute this workflow again, you will not get the desired result, as each Memory Store action is limited to one workflow run only.
Delete the stored Key-Value pair from Memory Store
IBM webMethods Integration allows you to delete stored key-value pairs from the Memory Store action.
To configure the second Memory Store action, select Delete from the drop-down list, specify the name of the key you want to delete, and then click Next.
Doing this will successfully delete the key and its associated value from the Memory Store action.