How to subscribe the event of ActivityTaskCompleted in code

Hi Team,

We have a biz case like below

  1. User trigger a workflow by calling a API.
  2. Workflow run couple of lines, and wait a signal.
  3. User send the signal to continue to run activity A
  4. workflow run other activities to end.

Our problem is, in Step 3, user need to know when the activity A real completed.

Is there any way to subscribe the event of “ActivityTaskCompleted” for Activity A in code? I cannot find info about this in Temporal docs.

Also, if the activity failed, how to monitoring the status and back to user? We run the workflow async.

Appreciate you help in advance.


I’m not sure I understand the question. You can invoke an activity synchronously. Then when the activity invokation returns then the activity is completed (which internally corresponds to ActivityTaskCompleted event). You can invoke an activity asynchronously in this case the activity completion causes its Promise to become ready.

Sorry for the confusion, let me clarify my question.

We have below workflow class

//Workflow Method
public void startWorkflow(){

//Signal Method
public void startStep2(){
     this.signalToStartStep2 = true 

And there is a RestController to recieve signal like below.

public class RestController{
    public boolean startStep2(){
         // Block here to wait the StepTwo activity real completed.

We are looking for a way to get the activity status in RestController.StartStep2 method.
Once the activity run to success, then back true to the API caller.

Any advice? Can we subscribe the ActivityComplated event in RestController?

Thank you very much.

I see. What you really want is the workflow synchronous update feature which we don’t have yet. This post provides a couple of workarounds.

Thank you. Maxim.

Do we have a plan to support this feature? or do we have a sample for the second solution - “local activity”.

We can try to implement this in our local. Polling query method is not appropriate for our project.

We do plan to support this feature. But it is a nontrivial project which is going to take a while to design and implement. So don’t rely on its availability any time soon.