ElFitz
ElFitz

Reputation: 988

How to send TaskSuccess to the right activity with AWS Step Functions?

So, I'm working on a state machine. It can have up to 20 or 30 executions of it running at the same time, with different parameters.

One of it's states is an activity worker (needs to wait for some input from another step function execution started from one of it's states through a lambda function, since you can't directly start a new execution from a state machine).

I know how to send a "Task Success" for an activity. But how can I make sure it's sent to the right execution ?

Upvotes: 0

Views: 1275

Answers (2)

ivo
ivo

Reputation: 1113

Depending on the design of your state machine, you may also be able to pass the current activity's taskToken as an input parameter when your activity creates a new StepFunction execution. Then the last state in the sub-execution can call Task Success for the state in the parent execution using the taskToken passed in, returning any result data as the results for that state. (Don't forget the last state would also have to call Task Success for itself as well.)

Upvotes: 0

Murali Allada
Murali Allada

Reputation: 22908

Using a pub/sub service such as mqtt would be useful here.

  1. Generate a UUID in the lambda that spawns the new execution.
  2. Pass the UUID to the new execution and return it to the activity worker.
  3. The new execution writes the UUID and result to the queue once it's done.
  4. The activity worker reads from the queue and uses the UUID to find the right message.

Upvotes: 1

Related Questions