Avoid/Handle Duplicate Signals

Hi @Maxim

I have one scenario where in a single workflow I am triggering multiple signals. Now the requirement is:

For example:

  1. In a workflow there are 2 signals signal1 and signal2

  2. Now after completing the signal1 my workflow is waiting for signal2

  3. And some how some one triggered the signal1 again so I want to block that signal1 from getting triggered because it is already waiting for signal2.

  4. And I do not want to go in the exception scenario or how should I handle that.

  5. Is there is any way to get the status of workflow that determines the signal name for which it is waiting for.


One way is to have an instance variable to record whether your workflow has received signal1, and ignore
signal1 the next time it arrives.

in java it would be something like

    public void signal1(Signal signal1){
      if(!this.signal1Received){ //or this.signal1 != null
        this.signal1Received = true;
        this.signal1 = signal1;

You can set the status before your await block and implement a query to retrieve the workflow status,

And some how some one triggered the signal1 again so I want to block that signal1 from getting triggered because it is already waiting for signal2.

What do you mean with “block”, for it to be ignored, processed after signal 2, processed in some order based on business logic, for example once s1 is received you want to ignore any other s1 for the remainder of the workflow execution?

If you are looking at signal ordering logic we went over this in worksop here. Should be able to extend that lock sample to do any custom ordering logic if you need.

1 Like

Hi @tihomir

My code flow is like I am having a jms message receiver from there I am signaling to my workflow based on different condition to start further execution.

And my entry point for signalling is that jms receiver only. And it can trigger same signal based on different values and then internally workflow will be having multiple waiting condition based on signals.

Let say on jms receiver I have received a message with condition x and I had triggered a signal (signal1) to workflow based on condition x to get started for execution now in the same workflow execution after signal1 completion it is waiting for another signal(signal2)
till my workflow is waiting for signal2 I wanted that till the signal2 is not completed with its execution I should not accept any signals (say signal3) and I am triggering signals from my jms receiver so how my jms receiver will know that some signalling condition is there which is waiting for its completion and if my jms receiver receives a message with condition y it should not trigger that untill signal2 is in execution state.

Some how I wanted to intimate my jms receiver that hey workflow is waiting for some external signal to get completed if it is in waiting state we should not trigger the next signal. After completion my receiver will get to know that signal has completed its execution we can send next signal.

Could you please help with this scenario in a detailed manner.

Thanks for sharing your use case, can you just confirm which SDK you are using (its not tagged on post)?

I am using Temporal SDK 1.16.0

There is no way to reject a signal. It is always accepted. The workflow can process them in any order it desires after that. This works for the majority of situations without any problem.

We are working on the synchronous update feature. It would be like a query, but it will be able to change the workflow state. It also would support rejecting updates without writing them to the history.