Clarification on context stores please

Hi.

Using flow context stores, are these unique for each process.

For example: The flow is triggered and flow uses flow context store to keep say count of something, while the flow is running. The flow gets triggered again, so now we have the flow running two different sets of input data. Is the flow context shared between the two flow or is the flow context unique to each process.

Say I was counting some thing, the first process that was triggered is up to 10. the next trigger comes in does that start at 0 or would it add to the existing 10?

Trying to keep flow data but keep it unique for that instance.

Thanks
Harry

No, in your example you would save the first 'trigger' value to context, for example 10.
When the second 'trigger' arrives, you would first retrieve the saved value - 10 and then continue adding to it before saving it back again to context.

context data is only unique in scope (node, flow. global), not instance.

if you want to keep a context unique for each count you could do something like this
flow.set("count." + unique_id, "some_data")
this would produce an object with individual properties for each instance.
e.g

{
"count": {
    "id1": 10,
    "id2":16,
    "id_etc": 12
    }
}

you would retrieve the individual unique id's with
flow.get("count." + unique_id)
or all id counts
flow.get("count")

Thanks for the feed back, thats what we thought but want clarification. We need to store flow context unique to each trigger. We will use a unique id like the message id or something and delete it once the flow is finished.

Thanks
Harry

Are you sure you need to use context? Possibly you can save the information you want in a message attribute so that it flows down with the message. Nodes should not change the content of attributes that they do not use (though not all nodes follow this convention).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.