Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-8310

Any incoming event should be able to match any workflow data when using correlations

XMLWordPrintable

      The workflow must correlate with the given event attribute despite the state where the instance is.

      For example, a workflow with an event definition like this one:

      "events": [
              {
                  "name": "CreditCheckCompletedEvent",
                  "type": "creditCheckCompleteType",
                  "source": "creditCheckSource",
                  "correlation": [
                    {
                      "contextAttributeName": "customerId"
                    }
                 ]
              }
          ],
      

      The instance must correlate with this event despite the state and the way the workflow started. So, in the states, we might have:

      "states": [
              {
                  "name": "CheckCustomer",
                  "type": "operation",
                  "actions": [{
                      "functionRef": {
                          "refName": "callCheckCustomerService",
                          "arguments": {
                              "customer": "${ .customer }"
                          }
                    }],
                   "transition": "CheckCredit"
               },
              {
                  "name": "CheckCredit",
                  "type": "callback",
                  "action": {
                      "functionRef": {
                          "refName": "callCreditCheckMicroservice",
                          "arguments": {
                              "customer": "${ .customer }"
                          }
                      }
                  },
                  "eventRef": "CreditCheckCompletedEvent",
                  "end": true
              }
      ]
      

      Note that the customer data model is already presented in the workflow context after running the first two states. In the callback state, the workflow should be able to resume if receive an event like this one:

      {
        "specversion" : "1.0",
        "type" : "creditCheckCompleteType",
        "datacontenttype" : "application/json",
        ...
        "data": {
          "creditCheck": [
              {
                "customerId": "customer123",
                "score": 580,
                "decision": "Denied",
                "reason": "Low credit score. Recent late payments"
              }
            ]
        }
      }
      

      Note the customerId field in the CE data payload.

      Note that the customerId field could also be an extension field:

      {
        "specversion" : "1.0",
        "type" : "creditCheckCompleteType",
        "datacontenttype" : "application/json",
        "customerId": "12345", 
        ...
        "data": {
          "creditCheck": [
              {
                "score": 580,
                "decision": "Denied",
                "reason": "Low credit score. Recent late payments"
              }
            ]
        }
      }
      

            rhn-support-zanini Ricardo Zanini
            rhn-support-zanini Ricardo Zanini
            Marian Macik Marian Macik
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: