-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
In the GetUser step
- kind: openapi
stepId: GetUser
operationId: $sourceDescriptions.UserEmailApi.getUserByEmail
parameters:
- name: email
in: query
value: $inputs.email
successCriteria:
- condition: $statusCode == 200
outputs:
userId: $response.body#/id #Storing userId for later use
onFailure:
- condition: $statusCode == 404
type: goto
step: CreateUser
onSuccess:
- condition: $statusCode == 200
goto: WaitForUserAck #Jumping to the WaitForUserAck stepIf the user exists, we are storing the userId to be used later in the WaitForUserAck step.
However, in the WaitForUserAck steps:
- kind: asyncapi
stepId: WaitForUserAck
operationId: $sourceDescriptions.EventBus.receiveUserAck
action: receive
correlationId: $steps.CreateUser.outputs.userCorrelationId # If we come from GetUser, correlationId won't exist
timeout: 10000
successCriteria:
- condition: $message.payload.status == "ok"
outputs:
userId: $message.payload.userId #Here again we are storing the userId, but we already have the userId from GetUser stepIdeally, from GetUser onSuccess we should go to SendPaymentRequest step since we already have the userId. However, there is a complication. In the SendPaymentRequest step:
- kind: asyncapi
stepId: SendPaymentRequest
operationId: $sourceDescriptions.EventBus.sendPaymentRequest
dependsOn:
- $steps.WaitForUserAck # if we come from GetUser step, then we cannot depend on WaitForUserAck step
action: send
requestBody:
contentType: application/json
# This payload assumes that user was created via CreateUser step and fetched via the WaitForUserAck step. It completely ignores if the user already existed.
payload: |
{
"userId": "{$steps.WaitForUserAck.outputs.userId}",
"productId": "{$inputs.productId}",
"orderId": "{$inputs.orderId}",
"amount": "{$inputs.amount}"
}
parameters:
- name: correlationId
in: header
value: "{$inputs.orderId}"Looks like we've a limitation in Arazzo Spec, we need an ability for 2 steps to update some global variable state, which can be then referenced by other steps. In this case, both GetUser and WaitForUserAck step should update userId in some global state, so that subsequent steps can pick the userId from the global state irrespective of which step was executed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels