# Examples ## Table of Contents - [Hello World](#Hello-World-Example) - [Greeting](#Greeting-Example) - [Event-based greeting](#Event-Based-Greeting-Example) - [Solving Math Problems (ForEach state)](#Solving-Math-Problems-Example) - [Parallel Execution](#Parallel-Execution-Example) - [Applicant Request Decision (Switch + SubFlow states)](#Applicant-Request-Decision-Example) - [Provision Orders (Error Handling)](#Provision-Orders-Example) - [Monitor Job for completion (Polling)](#Monitor-Job-Example) - [Send CloudEvent on Workflow Completion](#Send-CloudEvent-On-Workfow-Completion-Example) - [Monitor Patient Vital Signs (Event state)](#Monitor-Patient-Vital-Signs-Example) - [Finalize College Application (Event state)](#Finalize-College-Application-Example) - [Perform Customer Credit Check (Callback state)](#Perform-Customer-Credit-Check-Example) - [Handle Car Auction Bids (Scheduled start Event state)](#Handle-Car-Auction-Bids-Example) ### Hello World Example #### Description This example uses two inject states. The "Hello" state statically injects the following JSON into its data input: ```json { "result": "Hello" } ``` which then becomes the data input of the transition "World" state. The "World" state merges its data input with it's injected JSON and uses a filter to set its data output to the value of the "result" property. Since it is an end state, it's data output becomes the workflow data output: ```text "Hello World!" ``` #### Workflow Definition
JSON | YAML |
---|---|
```json { "id": "helloworld", "version": "1.0", "name": "Hello World Workflow", "description": "Static Hello World", "states":[ { "name":"Hello", "type":"INJECT", "start": { "kind": "DEFAULT" }, "data": { "result": "Hello" }, "transition": { "nextState": "World" } }, { "name":"World", "type":"INJECT", "data": { "result": " World!" }, "stateDataFilter": { "dataOutputPath": "$.result" }, "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: helloworld version: '1.0' name: Hello World Workflow description: Static Hello World states: - name: Hello type: INJECT start: kind: DEFAULT data: result: Hello transition: nextState: World - name: World type: INJECT data: result: " World!" stateDataFilter: dataOutputPath: "$.result" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "greeting", "version": "1.0", "name": "Greeting Workflow", "description": "Greet Someone", "functions": [ { "name": "greetingFunction", "resource": "functionResourse" } ], "states":[ { "name":"Greet", "type":"OPERATION", "start": { "kind": "DEFAULT" }, "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "greetingFunction", "parameters": { "name": "$.greet.name" } }, "actionDataFilter": { "dataResultsPath": "$.payload.greeting" } } ], "stateDataFilter": { "dataOutputPath": "$.greeting" }, "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: greeting version: '1.0' name: Greeting Workflow description: Greet Someone functions: - name: greetingFunction resource: functionResourse states: - name: Greet type: OPERATION start: kind: DEFAULT actionMode: SEQUENTIAL actions: - functionRef: refName: greetingFunction parameters: name: "$.greet.name" actionDataFilter: dataResultsPath: "$.payload.greeting" stateDataFilter: dataOutputPath: "$.greeting" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "eventbasedgreeting", "version": "1.0", "name": "Event Based Greeting Workflow", "description": "Event Based Greeting", "events": [ { "name": "GreetingEvent", "type": "greetingEventType", "source": "greetingEventSource" } ], "functions": [ { "name": "greetingFunction", "resource": "functionResourse" } ], "states":[ { "name":"Greet", "type":"EVENT", "start": { "kind": "DEFAULT" }, "eventsActions": [{ "eventRefs": ["GreetingEvent"], "eventDataFilter": { "inputPath": "$.data.greet" }, "actions":[ { "functionRef": { "refName": "greetingFunction", "parameters": { "name": "$.greet.name" } } } ] }], "stateDataFilter": { "dataOutputPath": "$.payload.greeting" }, "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: eventbasedgreeting version: '1.0' name: Event Based Greeting Workflow description: Event Based Greeting events: - name: GreetingEvent type: greetingEventType source: greetingEventSource functions: - name: greetingFunction resource: functionResourse states: - name: Greet type: EVENT start: kind: DEFAULT eventsActions: - eventRefs: - GreetingEvent eventDataFilter: inputPath: "$.data.greet" actions: - functionRef: refName: greetingFunction parameters: name: "$.greet.name" stateDataFilter: dataOutputPath: "$.payload.greeting" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "solvemathproblems", "version": "1.0", "name": "Solve Math Problems Workflow", "description": "Solve math problems", "functions": [ { "name": "solveMathExpressionFunction", "resource": "functionResourse" } ], "states":[ { "name":"Solve", "start": { "kind": "DEFAULT" }, "type":"FOREACH", "inputCollection": "$.expressions", "inputParameter": "$.singleexpression", "outputCollection": "$.results", "states": [ { "name":"GetResults", "type":"OPERATION", "start": { "kind": "DEFAULT" }, "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "solveMathExpressionFunction", "parameters": { "expression": "$.singleexpression" } } } ], "end": { "kind": "DEFAULT" } } ], "stateDataFilter": { "dataOutputPath": "$.results" }, "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: solvemathproblems version: '1.0' name: Solve Math Problems Workflow description: Solve math problems functions: - name: solveMathExpressionFunction resource: functionResourse states: - name: Solve start: kind: DEFAULT type: FOREACH inputCollection: "$.expressions" inputParameter: "$.singleexpression" outputCollection: "$.results" states: - name: GetResults type: OPERATION start: kind: DEFAULT actionMode: SEQUENTIAL actions: - functionRef: refName: solveMathExpressionFunction parameters: expression: "$.singleexpression" end: kind: DEFAULT stateDataFilter: dataOutputPath: "$.results" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "parallelexec", "version": "1.0", "name": "Parallel Execution Workflow", "description": "Executes two branches in parallel", "states":[ { "name":"ParallelExec", "type":"PARALLEL", "start": { "kind": "DEFAULT" }, "completionType": "AND", "branches": [ { "name": "Branch1", "states": [ { "name":"ShortDelay", "type":"DELAY", "start": { "kind": "DEFAULT" }, "timeDelay": "PT15S", "end": { "kind": "DEFAULT" } } ] }, { "name": "Branch2", "states": [ { "name":"LongDelay", "type":"DELAY", "start": { "kind": "DEFAULT" }, "timeDelay": "PT2M", "end": { "kind": "DEFAULT" } } ] } ], "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: parallelexec version: '1.0' name: Parallel Execution Workflow description: Executes two branches in parallel states: - name: ParallelExec type: PARALLEL start: kind: DEFAULT branches: completionType: AND - name: Branch1 states: - name: ShortDelay type: DELAY start: kind: DEFAULT timeDelay: PT15S end: kind: DEFAULT - name: Branch2 states: - name: LongDelay type: DELAY start: kind: DEFAULT timeDelay: PT2M end: kind: DEFAULT end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "applicantrequest", "version": "1.0", "name": "Applicant Request Decision Workflow", "description": "Determine if applicant request is valid", "functions": [ { "name": "sendRejectionEmailFunction", "resource": "functionResourse" } ], "states":[ { "name":"CheckApplication", "type":"SWITCH", "start": { "kind": "DEFAULT" }, "conditions": [ { "path": "$.applicant.age", "value": "18", "operator": "GreaterThanOrEquals", "transition": { "nextState": "StartApplication" } }, { "path": "$.applicant.age", "value": "18", "operator": "LessThan", "transition": { "nextState": "RejectApplication" } } ], "default": { "nextState": "RejectApplication" } }, { "name": "StartApplication", "type": "SUBFLOW", "workflowId": "startApplicationWorkflowId", "end": { "kind": "DEFAULT" } }, { "name":"RejectApplication", "type":"OPERATION", "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "sendRejectionEmailFunction", "parameters": { "applicant": "$.applicant" } } } ], "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: applicantrequest version: '1.0' name: Applicant Request Decision Workflow description: Determine if applicant request is valid functions: - name: sendRejectionEmailFunction resource: functionResourse states: - name: CheckApplication type: SWITCH start: kind: DEFAULT conditions: - path: "$.applicant.age" value: '18' operator: GreaterThanOrEquals transition: nextState: StartApplication - path: "$.applicant.age" value: '18' operator: LessThan transition: nextState: RejectApplication default: nextState: RejectApplication - name: StartApplication type: SUBFLOW workflowId: startApplicationWorkflowId end: kind: DEFAULT - name: RejectApplication type: OPERATION actionMode: SEQUENTIAL actions: - functionRef: refName: sendRejectionEmailFunction parameters: applicant: "$.applicant" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "provisionorders", "version": "1.0", "name": "Provision Orders", "description": "Provision Orders and handle errors thrown", "functions": [ { "name": "provisionOrderFunction", "resource": "functionResourse" } ], "states":[ { "name":"ProvisionOrder", "type":"OPERATION", "start": { "kind": "DEFAULT" }, "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "provisionOrderFunction", "parameters": { "order": "$.order" } } } ], "onError": [ { "expression": { "language": "spel", "body": "name eq 'MissingOrderIdException'" }, "transition": { "nextState": "MissingId" } }, { "expression": { "language": "spel", "body": "name eq 'MissingOrderItemException'" }, "transition": { "nextState": "MissingItem" } }, { "expression": { "language": "spel", "body": "name eq 'MissingOrderQuantityException'" }, "transition": { "nextState": "MissingQuantity" } } ], "stateDataFilter": { "dataOutputPath": "$.exception" }, "transition": { "nextState":"ApplyOrder" } }, { "name": "MissingId", "type": "SUBFLOW", "workflowId": "handleMissingIdExceptionWorkflow", "end": { "kind": "DEFAULT" } }, { "name": "MissingItem", "type": "SUBFLOW", "workflowId": "handleMissingItemExceptionWorkflow", "end": { "kind": "DEFAULT" } }, { "name": "MissingQuantity", "type": "SUBFLOW", "workflowId": "handleMissingQuantityExceptionWorkflow", "end": { "kind": "DEFAULT" } }, { "name": "ApplyOrder", "type": "SUBFLOW", "workflowId": "applyOrderWorkflowId", "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: provisionorders version: '1.0' name: Provision Orders description: Provision Orders and handle errors thrown functions: - name: provisionOrderFunction resource: functionResourse states: - name: ProvisionOrder type: OPERATION start: kind: DEFAULT actionMode: SEQUENTIAL actions: - functionRef: refName: provisionOrderFunction parameters: order: "$.order" onError: - expression: language: spel body: name eq 'MissingOrderIdException' transition: nextState: MissingId - expression: language: spel body: name eq 'MissingOrderItemException' transition: nextState: MissingItem - expression: language: spel body: name eq 'MissingOrderQuantityException' transition: nextState: MissingQuantity stateDataFilter: dataOutputPath: "$.exception" transition: nextState: ApplyOrder - name: MissingId type: SUBFLOW workflowId: handleMissingIdExceptionWorkflow end: kind: DEFAULT - name: MissingItem type: SUBFLOW workflowId: handleMissingItemExceptionWorkflow end: kind: DEFAULT - name: MissingQuantity type: SUBFLOW workflowId: handleMissingQuantityExceptionWorkflow end: kind: DEFAULT - name: ApplyOrder type: SUBFLOW workflowId: applyOrderWorkflowId end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "jobmonitoring", "version": "1.0", "name": "Job Monitoring", "description": "Monitor finished execution of a submitted job", "functions": [ { "name": "submitJob", "resource": "submitJobResource" }, { "name": "checkJobStatus", "resource": "checkJobStatusResource" }, { "name": "reportJobSuceeded", "resource": "reportJobSuceededResource" }, { "name": "reportJobFailed", "resource": "reportJobFailedResource" } ], "states":[ { "name":"SubmitJob", "type":"OPERATION", "start": { "kind": "DEFAULT" }, "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "submitJob", "parameters": { "name": "$.job.name" } }, "actionDataFilter": { "dataResultsPath": "$.jobuid" } } ], "onError": [ { "expression": { "language": "spel", "body": "$.exception != null" }, "errorDataFilter": { "dataOutputPath": "$.exception" }, "transition": { "nextState": "SubmitError" } } ], "stateDataFilter": { "dataOutputPath": "$.jobuid" }, "transition": { "nextState":"WaitForCompletion" } }, { "name": "SubmitError", "type": "SUBFLOW", "workflowId": "handleJobSubmissionErrorWorkflow", "end": { "kind": "DEFAULT" } }, { "name": "WaitForCompletion", "type": "DELAY", "timeDelay": "PT5S", "transition": { "nextState":"GetJobStatus" } }, { "name":"GetJobStatus", "type":"OPERATION", "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "checkJobStatus", "parameters": { "name": "$.jobuid" } }, "actionDataFilter": { "dataResultsPath": "$.jobstatus" } } ], "stateDataFilter": { "dataOutputPath": "$.jobstatus" }, "transition": { "nextState":"DetermineCompletion" } }, { "name":"DetermineCompletion", "type":"SWITCH", "conditions": [ { "path": "$.jobstatus", "value": "SUCCEEDED", "operator": "Equals", "transition": { "nextState": "JobSucceeded" } }, { "path": "$.jobstatus", "value": "FAILED", "operator": "Equals", "transition": { "nextState": "JobFailed" } } ], "default": { "nextState": "WaitForCompletion" } }, { "name":"JobSucceeded", "type":"OPERATION", "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "reportJobSuceeded", "parameters": { "name": "$.jobuid" } } } ], "end": { "kind": "DEFAULT" } }, { "name":"JobFailed", "type":"OPERATION", "actionMode":"SEQUENTIAL", "actions":[ { "functionRef": { "refName": "reportJobFailed", "parameters": { "name": "$.jobuid" } } } ], "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: jobmonitoring version: '1.0' name: Job Monitoring description: Monitor finished execution of a submitted job functions: - name: submitJob resource: submitJobResource - name: checkJobStatus resource: checkJobStatusResource - name: reportJobSuceeded resource: reportJobSuceededResource - name: reportJobFailed resource: reportJobFailedResource states: - name: SubmitJob type: OPERATION start: kind: DEFAULT actionMode: SEQUENTIAL actions: - functionRef: refName: submitJob parameters: name: "$.job.name" actionDataFilter: dataResultsPath: "$.jobuid" onError: - expression: language: spel body: "$.exception != null" errorDataFilter: dataOutputPath: "$.exception" transition: nextState: SubmitError stateDataFilter: dataOutputPath: "$.jobuid" transition: nextState: WaitForCompletion - name: SubmitError type: SUBFLOW workflowId: handleJobSubmissionErrorWorkflow end: kind: DEFAULT - name: WaitForCompletion type: DELAY timeDelay: PT5S transition: nextState: GetJobStatus - name: GetJobStatus type: OPERATION actionMode: SEQUENTIAL actions: - functionRef: refName: checkJobStatus parameters: name: "$.jobuid" actionDataFilter: dataResultsPath: "$.jobstatus" stateDataFilter: dataOutputPath: "$.jobstatus" transition: nextState: DetermineCompletion - name: DetermineCompletion type: SWITCH conditions: - path: "$.jobstatus" value: SUCCEEDED operator: Equals transition: nextState: JobSucceeded - path: "$.jobstatus" value: FAILED operator: Equals transition: nextState: JobFailed default: nextState: WaitForCompletion - name: JobSucceeded type: OPERATION actionMode: SEQUENTIAL actions: - functionRef: refName: reportJobSuceeded parameters: name: "$.jobuid" end: kind: DEFAULT - name: JobFailed type: OPERATION actionMode: SEQUENTIAL actions: - functionRef: refName: reportJobFailed parameters: name: "$.jobuid" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "sendcloudeventonprovision", "version": "1.0", "name": "Send CloudEvent on provision completion", "events": [ { "name": "provisioningCompleteEvent", "type": "provisionCompleteType", "source": "provisionCompleteSource" } ], "functions": [ { "name": "provisionOrderFunction", "resource": "functionResourse" } ], "states": [ { "name": "ProvisionOrdersState", "type": "FOREACH", "start": { "kind": "DEFAULT" }, "inputCollection": "$.orders", "inputParameter": "$.singleorder", "outputCollection": "$.results", "states": [ { "name": "DoProvision", "type": "OPERATION", "start": { "kind": "DEFAULT" }, "actionMode": "SEQUENTIAL", "actions": [ { "functionRef": { "refName": "provisionOrderFunction", "parameters": { "order": "$.order" } } } ], "end": { "kind": "DEFAULT" } } ], "stateDataFilter": { "dataOutputPath": "$.provisionedOrders" }, "end": { "kind": "EVENT", "produceEvent": { "nameRef": "provisioningCompleteEvent", "data": "$.provisionedOrders" } } } ] } ``` | ```yaml id: sendcloudeventonprovision version: '1.0' name: Send CloudEvent on provision completion events: - name: provisioningCompleteEvent type: provisionCompleteType source: provisionCompleteSource functions: - name: provisionOrderFunction resource: functionResourse states: - name: ProvisionOrdersState type: FOREACH start: kind: DEFAULT inputCollection: "$.orders" inputParameter: "$.singleorder" outputCollection: "$.results" states: - name: DoProvision type: OPERATION start: kind: DEFAULT actionMode: SEQUENTIAL actions: - functionRef: refName: provisionOrderFunction parameters: order: "$.order" end: kind: DEFAULT stateDataFilter: dataOutputPath: "$.provisionedOrders" end: kind: EVENT produceEvent: nameRef: provisioningCompleteEvent data: "$.provisionedOrders" ``` |
JSON | YAML |
---|---|
```json { "id": "patientVitalsWorkflow", "name": "Monitor Patient Vitals", "version": "1.0", "events": [ { "name": "HighBodyTemperature", "type": "org.monitor.highBodyTemp", "source": "monitoringSource", "correlationToken": "patientId" }, { "name": "HighBloodPressure", "type": "org.monitor.highBloodPressure", "source": "monitoringSource", "correlationToken": "patientId" }, { "name": "HighRespirationRate", "type": "org.monitor.highRespirationRate", "source": "monitoringSource", "correlationToken": "patientId" } ], "functions": [ { "name": "callPulmonologist", "type": "function", "resource": "callPulmonologistResource" }, { "name": "sendTylenolOrder", "type": "function", "resource": "sendTylenolOrderFunction" }, { "name": "callNurse", "type": "function", "resource": "callNurseResource" } ], "states": [ { "name": "MonitorVitals", "type": "EVENT", "start": { "kind": "DEFAULT" }, "exclusive": true, "eventsActions": [{ "eventRefs": ["HighBodyTemperature"], "actions": [{ "functionRef": { "refName": "sendTylenolOrder", "parameters": { "patientid": "$.patientId" } } }] }, { "eventRefs": ["HighBloodPressure"], "actions": [{ "functionRef": { "refName": "callNurse", "parameters": { "patientid": "$.patientId" } } }] }, { "eventRefs": ["HighRespirationRate"], "actions": [{ "functionRef": { "refName": "callPulmonologist", "parameters": { "patientid": "$.patientId" } } }] } ], "end": { "kind": "TERMINATE" } }] } ``` | ```yaml id: patientVitalsWorkflow name: Monitor Patient Vitals version: '1.0' events: - name: HighBodyTemperature type: org.monitor.highBodyTemp source: monitoringSource correlationToken: patientId - name: HighBloodPressure type: org.monitor.highBloodPressure source: monitoringSource correlationToken: patientId - name: HighRespirationRate type: org.monitor.highRespirationRate source: monitoringSource correlationToken: patientId functions: - name: callPulmonologist type: function resource: callPulmonologistResource - name: sendTylenolOrder type: function resource: sendTylenolOrderFunction - name: callNurse type: function resource: callNurseResource states: - name: MonitorVitals type: EVENT start: kind: DEFAULT exclusive: true eventsActions: - eventRefs: - HighBodyTemperature actions: - functionRef: refName: sendTylenolOrder parameters: patientid: "$.patientId" - eventRefs: - HighBloodPressure actions: - functionRef: refName: callNurse parameters: patientid: "$.patientId" - eventRefs: - HighRespirationRate actions: - functionRef: refName: callPulmonologist parameters: patientid: "$.patientId" end: kind: TERMINATE ``` |
JSON | YAML |
---|---|
```json { "id": "finalizeCollegeApplication", "name": "Finalize College Application", "version": "1.0", "events": [ { "name": "ApplicationSubmitted", "type": "org.application.submitted", "source": "applicationsource", "correlationToken": "applicantId" }, { "name": "SATScoresReceived", "type": "org.application.satscores", "source": "applicationsource", "correlationToken": "applicantId" }, { "name": "RecommendationLetterReceived", "type": "org.application.recommendationLetter", "source": "applicationsource", "correlationToken": "applicantId" } ], "functions": [ { "name": "finalizeApplicationFunction", "type": "function", "resource": "finalizeApplicationResource" } ], "states": [ { "name": "FinalizeApplication", "type": "EVENT", "start": { "kind": "DEFAULT" }, "exclusive": false, "eventsActions": [ { "eventRefs": [ "ApplicationSubmitted", "SATScoresReceived", "RecommendationLetterReceived" ], "actions": [ { "functionRef": { "refName": "finalizeApplicationFunction", "parameters": { "student": "$.applicantId" } } } ] } ], "end": { "kind": "TERMINATE" } } ] } ``` | ```yaml id: finalizeCollegeApplication name: Finalize College Application version: '1.0' events: - name: ApplicationSubmitted type: org.application.submitted source: applicationsource correlationToken: applicantId - name: SATScoresReceived type: org.application.satscores source: applicationsource correlationToken: applicantId - name: RecommendationLetterReceived type: org.application.recommendationLetter source: applicationsource correlationToken: applicantId functions: - name: finalizeApplicationFunction type: function resource: finalizeApplicationResource states: - name: FinalizeApplication type: EVENT start: kind: DEFAULT exclusive: false eventsActions: - eventRefs: - ApplicationSubmitted - SATScoresReceived - RecommendationLetterReceived actions: - functionRef: refName: finalizeApplicationFunction parameters: student: "$.applicantId" end: kind: TERMINATE ``` |
JSON | YAML |
---|---|
```json { "id": "customercreditcheck", "version": "1.0", "name": "Customer Credit Check Workflow", "description": "Perform Customer Credit Check", "functions": [ { "name": "callCreditCheckMicroservice", "resource": "creditCheckResource", "type": "microservice" }, { "name": "sendRejectionEmailFunction", "resource": "rejectEmailResource" } ], "events": [ { "name": "CreditCheckCompletedEvent", "type": "creditCheckCompleteType", "source": "creditCheckSource", "correlationToken": "customerId" } ], "states": [ { "name": "CheckCredit", "type": "CALLBACK", "start": { "kind": "DEFAULT" }, "action": { "functionRef": { "refName": "callCreditCheckMicroservice", "parameters": { "customer": "$.customer" } } }, "eventRef": "CreditCheckCompletedEvent", "timeout": "PT15M", "transition": { "nextState": "EvaluateDecision" } }, { "name": "EvaluateDecision", "type": "SWITCH", "conditions": [ { "path": "$.creditCheck.decision", "value": "Approved", "operator": "Equals", "transition": { "nextState": "StartApplication" } }, { "path": "$.creditCheck.decision", "value": "Denied", "operator": "Equals", "transition": { "nextState": "RejectApplication" } } ], "default": { "nextState": "RejectApplication" } }, { "name": "StartApplication", "type": "SUBFLOW", "workflowId": "startApplicationWorkflowId", "end": { "kind": "DEFAULT" } }, { "name": "RejectApplication", "type": "OPERATION", "actionMode": "SEQUENTIAL", "actions": [ { "functionRef": { "refName": "sendRejectionEmailFunction", "parameters": { "applicant": "$.customer" } } } ], "end": { "kind": "DEFAULT" } } ] } ``` | ```yaml id: customercreditcheck version: '1.0' name: Customer Credit Check Workflow description: Perform Customer Credit Check functions: - name: callCreditCheckMicroservice resource: creditCheckResource type: microservice - name: sendRejectionEmailFunction resource: rejectEmailResource events: - name: CreditCheckCompletedEvent type: creditCheckCompleteType source: creditCheckSource correlationToken: customerId states: - name: CheckCredit type: CALLBACK start: kind: DEFAULT action: functionRef: refName: callCreditCheckMicroservice parameters: customer: "$.customer" eventRef: CreditCheckCompletedEvent timeout: PT15M transition: nextState: EvaluateDecision - name: EvaluateDecision type: SWITCH conditions: - path: "$.creditCheck.decision" value: Approved operator: Equals transition: nextState: StartApplication - path: "$.creditCheck.decision" value: Denied operator: Equals transition: nextState: RejectApplication default: nextState: RejectApplication - name: StartApplication type: SUBFLOW workflowId: startApplicationWorkflowId end: kind: DEFAULT - name: RejectApplication type: OPERATION actionMode: SEQUENTIAL actions: - functionRef: refName: sendRejectionEmailFunction parameters: applicant: "$.customer" end: kind: DEFAULT ``` |
JSON | YAML |
---|---|
```json { "id": "handleCarAuctionBid", "version": "1.0", "name": "Car Auction Bidding Workflow", "description": "Store a single bid whole the car auction is active", "functions": [ { "name": "StoreBidFunction", "resource": "storeBidResource", "type": "function" } ], "events": [ { "name": "CarBidEvent", "type": "carBidMadeType", "source": "carBidEventSource" } ], "states": [ { "name": "StoreCarAuctionBid", "type": "EVENT", "start": { "kind": "SCHEDULED", "schedule": { "interval": "2020-03-20T09:00:00Z/2020-03-20T15:00:00Z" } }, "exclusive": true, "eventsActions": [ { "eventRefs": ["CarBidEvent"], "actions": [{ "functionRef": { "refName": "StoreBidFunction", "parameters": { "bid": "$.bid" } } }] } ], "end": { "kind": "TERMINATE" } } ] } ``` | ```yaml id: handleCarAuctionBid version: '1.0' name: Car Auction Bidding Workflow description: Store a single bid whole the car auction is active functions: - name: StoreBidFunction resource: storeBidResource type: function events: - name: CarBidEvent type: carBidMadeType source: carBidEventSource states: - name: StoreCarAuctionBid type: EVENT start: kind: SCHEDULED schedule: interval: 2020-03-20T09:00:00Z/2020-03-20T15:00:00Z exclusive: true eventsActions: - eventRefs: - CarBidEvent actions: - functionRef: refName: StoreBidFunction parameters: bid: "$.bid" end: kind: TERMINATE ``` |