Is there away to prevent publishing messages to a message catch in an instance after the instance is completed?


If I have a message catch in an instance like this:

In my case I will be making multiple instances like this and will be getting messages that may have the same message name and correlation key. What I would like to be able to do is that when an instance is started and a message is published and the instance reaches the end and is marked as Completed, I want to use the Completed status of the instance to prevent any future messages to be published to the completed instance.
Is this possible?

Hi @Nima_Namjouyan,

thank you for raising this up.

In general, it is not possible to prevent that a message is published (expect using a message id). Message are independent from process instances.

To be precise, no message can be correlated to the process instance if it is completed.

What exactly do you want to achieve by “not publishing a message”?

Best regards,


I think I know where I was going wrong.

So this is what I think was happening:

  1. I would start an instance with a variable containing a correlation field of interest.

  2. I would wait for a message to be published to a receive task with a timer boundary event of 5 seconds. This way if a message was not published in 5 seconds, the workflow would take an alternate path and reach the end of the flow. The instance would reach “completed” stage.

  3. If the message were to arrive after 5 seconds and the completion of the instance, it should create a new instance and then the instance would again wait for another message to be published in 5 seconds or it would take an alternate path to completion again.

I did not know and have the code to create a new instance after the 5 seconds. So sometimes a message would arrive after 5 seconds and would be published to receive task after the instance had been completed already. This was really confusing me and resulted in an ambiguous stage. So I had to somehow make my publishing/instance making code be aware of the boundary event timer so it would know when to make a new instance and when it is still ok to publish to the receive task event.

Thanks for your help.

Thanks for sharing!

Just for reference, one way to prevent the message collection to a newer instance could be to use a different correlation key for the new process instance.

1 Like