Idempotency and HistoryService

Hi

I want to implement idempotency for the creation of new process instances. New processes are created by incoming messages (in a MessageListener).
The message payload has a ProcessDefinitionKey and arbitrary variables incl. a BusinessKey.
Goal: Duplicate messages must not start a process again (no time constraint yet).

Defintions in this Context:
Two messages are the same (Duplicates) when the ProcessDefinitionKey and all Variables in the message payload are the same (Payload is a JSON String).
We do not want to rely on the unique constraint for the business key - or at least not for now, although this might be the easiest approach to achieve idempotency.

For the implementation I looked at the HistoryService as the “Cache” for identifying Duplicates. There I need to query:

  • processes with a given ProcessDefinitionKey and initial variables, i.e. variable values at the start of the process.

It seems that I can’t get this info form the HistoryService (HistoricProcessInstanceQuery ?) or I could not find it yet.

Any help on this topic?

When the message is received, do you want a correlation to occur with the process definition or do you want the correlation to fail?

option that comes to mind is to create a second definition that receives the messages from the outside source and run a check such as:

And then decide to re-correlate the message to the ‘real’ process definition using a script task.

Hi

This thread may be of interest…

You could consider normalising your process variable name/value pairs, then producing a hash of the content and storing it as another process variable. This hash would represent the initial state which would not change with subsequent updates. Thus you can also perform a variable query through history using this value which should be more efficient than scanning for multiple variables…

regards

Rob

Nice post rob. Had not seen that one. Good writeup