You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our workflow starts with the "Place Order" [Subflow](../specification.md#SubFlow-State), which is responsible
3890
+
to send the received order to the requested restaurant and the estimated order ETA.
3891
+
We then wait for the ETA time when our workflow should go into the "Deliver Order" SubFlow, responsible
3892
+
for dispatching a Courier and sending her/him off to pick up the order. Once the order is picked up, the Courier needs to deliver the order to the customer.
3893
+
After the order has been delivered to the customer, our workflow needs to charge the customer.
3894
+
3895
+
Our workflow needs to communicate with three services during its execution, namely the Order, Delivery, and
3896
+
the Payment services.
3897
+
3898
+
For the sake of the example, we assume that our workflow can communicate to the Order and Delivery services via REST and the Payment service via gRPC.
3899
+
Let's start by defining an example CloudEvent which triggers an instance of our workflow.
3900
+
This event can be sent by a web UI, for example, or be pushed onto a Kafka/MQTT topic to start our order workflow.
3901
+
3902
+
```json
3903
+
{
3904
+
"specversion": "1.0",
3905
+
"type": "org.orders",
3906
+
"source": "/orders/",
3907
+
"subject": "Food Order",
3908
+
"id": "A234-1234-1234",
3909
+
"time": "2021-03-05T17:31:00Z",
3910
+
"orderid": "ORDER-12345",
3911
+
"data": {
3912
+
"id": "ORDER-12345",
3913
+
"customerId": "CUSTOMER-12345",
3914
+
"status": [],
3915
+
"order": {
3916
+
"restaurantId": "RESTAURANT-54321",
3917
+
"items": [
3918
+
{
3919
+
"itemId": "ITEM-8765",
3920
+
"amount": 1,
3921
+
"addons": ""
3922
+
}
3923
+
]
3924
+
},
3925
+
"delivery":{
3926
+
"address": "1234 MyStreet, MyCountry",
3927
+
"type": "contactless",
3928
+
"requestedTime": "ASAP",
3929
+
"location": "Front door",
3930
+
"instructions": ""
3931
+
}
3932
+
}
3933
+
}
3934
+
```
3935
+
3936
+
Note the `orderid` CloudEvent context attribute, which contains the unique ID of the order specified in this event. [Event correlation](../specification.md#Correlation-Definition) is done against CE context attributes, and as such, to be able
3937
+
to correlate multiple order events to the same order id, it needs to be part of the CE context attributes, and
3938
+
not its data (payload).
3939
+
3940
+
Now let's start defining our workflow. For the sake of this example, let's define our function and event definitions
3941
+
as separate YAML files (and then reference them inside our workflow definition). This is useful in cases
3942
+
when you want to reuse them between multiple workflow definitions.
0 commit comments