Skip to content

Instantly share code, notes, and snippets.

@ricardozanini
Created April 15, 2021 18:20
Show Gist options
  • Save ricardozanini/c4d40b77b4e827b8ecb88de97c533e06 to your computer and use it in GitHub Desktop.
Save ricardozanini/c4d40b77b4e827b8ecb88de97c533e06 to your computer and use it in GitHub Desktop.
Kogito Serverless Workflow Order Processing Example
id: fraudhandling
name: Fraud Handling
start: FraudHandling
version: "1.0"
events:
- kind: produced
name: FraudEvaluation
type: orders.fraudEvaluation
source: fraudEvaluation
states:
- name: FraudHandling
type: switch
dataConditions:
- condition: "{{ $.[?(@.total > 1000)] }}"
transition: FraudVerificationNeeded
- condition: "{{ $.[?(@.total <= 1000)] }}"
end: true
- name: FraudVerificationNeeded
type: inject
data:
fraudEvaluation: true
end:
produceEvents:
- eventRef: FraudEvaluation
name: Order Workflow
id: orderworkflow
version: "1.0"
description: Workflow for processing Orders and produce Logistics Events
start: ReceiveOrder
events:
- kind: consumed
name: OrderEvent
type: orderEvent
source: orderEvent
states:
- name: ReceiveOrder
type: event
onEvents:
- eventRefs:
- "OrderEvent"
transition: ProcessOrder
- name: ProcessOrder
type: parallel
branches:
- name: HandleFraudEvaluation
workflowId: fraudhandling
- name: HandleShippingType
workflowId: shippinghandling
completionType: and
end: true
id: shippinghandling
name: Shipping Handling
start: ShippingHandling
version: "1.0"
events:
- kind: produced
name: InternationalShippingOrder
type: internationalShipping
source: internationalShipping
- kind: produced
name: DomesticShippingOrder
type: domesticShipping
source: domesticShipping
states:
- name: ShippingHandling
type: switch
dataConditions:
- condition: "{{ $.[?(@.country == 'US')] }}"
transition: DomesticShipping
- condition: "{{ $.[?(@.country != 'US')] }}"
transition: InternationalShipping
- name: DomesticShipping
type: inject
data:
shipping: "domestic"
end:
produceEvents:
- eventRef: DomesticShippingOrder
- name: InternationalShipping
type: inject
data:
shipping: "international"
end:
produceEvents:
- eventRef: "InternationalShippingOrder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment