How to purge (clear, remove) the pending messages with a given target and correlation ?

Hello,

I use a message to trigger an action in my workflow. This message is sent from an external application, using the name of the workflow and the name of the task as target, and some instance data as correlation.

This works well but if such a message is sent BEFORE the tasks starts, or even before the workflow starts, the message is kept in a queue, and triggers the action as soon as the task becomes active.

I want to make sure that ONLY the messages sent AFTER the beginning of the task are taken. In other words I want that the older messages are discarded, if any, when the task is started.

Is it possible ? For instance, is it possible to purge the messages having the relevant process name, task name, and correlation data through the API ? Or is there any other way to make sure that only new messages trigger the action ?

Thank you,
Michel

Yes - it is possible to clear messages, but not (that I have found) through a supported API. They are stored in the “bonita_journal” DB, “message_instance” table. However updating the table could have bad consequences and I’m pretty sure would be unsupported.

So - how about changing the design. ALLOW messages out of your time window but DROP them once they are received. One way would be to include a time stamp in the message, and keep a time stamp for the time the task starts - that way you can compare them when the message is received and loop back to retry the receive if the times dont match up as you expect.