Integrate CloudFlow with EventBridge

更新时间:
复制 MD 格式

CloudFlow integrates with EventBridge through the EventBridge:PutEvents action, which publishes events from a workflow task node to an event bus. This triggers downstream event-driven processing without custom API code.

Two integration modes are available:

  • RequestComplete -- The task completes as soon as EventBridge acknowledges the request. Use this when the workflow does not depend on downstream event processing.

  • WaitForCustomCallback -- The task pauses the workflow until an external system reports the result through a callback. Use this when the workflow must wait for a downstream consumer to finish.

Workflow definition

The following YAML defines a workflow that publishes an event to EventBridge:

Type: StateMachine
Name: MyWorkflow
SpecVersion: v1
StartAt: PutEvents
States:
  - Type: Task
    Name: PutEvents
    Action: EventBridge:PutEvents
    TaskMode: RequestComplete
    Description: an example of integration with EventBridge
    Parameters:
      id: xxxxx-xxxx-xxxx-xxxx
      type: aliyuncvc:MeetingEvent:MemberOperate
      eventBusName: fnf-eb-bus
      subject: test-subject
      source: test-source
      data:
        eventContent:
          key1: val1
          key2: val2
    End: true

Configure the following fields in the Task state:

FieldValueDescription
ActionEventBridge:PutEventsPublishes events to the specified event bus
TaskModeRequestComplete or WaitForCustomCallbackControls whether the workflow continues immediately or waits for a callback. See Integration modes
NameCustomDescriptive name for the task
DescriptionCustomBrief description of the task purpose

Parameters

The Parameters block defines the event payload. Fields align with the CloudEvents specification.

Required parameters

ParameterTypeDescriptionExample
idStringUnique event identifier. Producers must ensure that source + id is unique per event. EventBridge uses this value for tracking and deduplication.45ef4dewdwe1-7c35-447a-bd93-fab****
sourceStringEvent source identifier. Specifies the service or context that produced the event.acs:aliyuncvc
typeStringEvent type. Used for routing, querying, and policy enforcement. The format is defined by the producer and includes information such as the version number.aliyuncvc:MeetingEvent:MemberOperate
eventBusNameStringTarget event bus name. This field is specific to EventBridge and is not part of the CloudEvents specification.default

Optional parameters

ParameterTypeDescriptionExample
subjectStringEvent subject. Defaults to the Alibaba Cloud Resource Name (ARN) of the current workflow. Use this for fine-grained subscription filtering when data alone is insufficient.acs.fnf:cn-hangzhou:{AccountId}:215672
dataObjectEvent payload. The structure is determined by the event source.See the example below

data example:

data:
  meetingName: swqd
  groupId: 456
  action: camera_off
  time: 1590592527490
  userId: 199525****
  meetingUUID: hz-20864c8f-b10d-45cd-9935-884bca1b****

Return value

PutEvents returns a JSON object that contains the result of each event entry:

{
    "EntryList": [
        {
            "ErrorCode": null,
            "ErrorMessage": null,
            "EventID": "61fcd09a-eb42-48fb-9bf5-*********",
            "TraceID": "4C9FEA1480767FDA352**********"
        }
    ],
    "FailedEntryCount": 0,
    "RequestID": "6538799543**************",
    "ResourceOwnerAccountID": null
}
FieldDescription
EntryListArray of result entries, one per event
ErrorCodeError code for the entry. null on success
ErrorMessageError message for the entry. null on success
EventIDUnique identifier assigned by EventBridge
TraceIDTrace identifier for event tracking
FailedEntryCountNumber of failed entries. 0 means all events were published
RequestIDUnique request identifier
ResourceOwnerAccountIDResource owner account ID

Integration modes

RequestComplete

The task completes as soon as EventBridge acknowledges the PutEvents request. The workflow advances to the next state immediately.

Use this mode when downstream event processing does not affect the workflow outcome.

WaitForCustomCallback

The task pauses the workflow after delivering the event. The workflow remains suspended until an external system calls ReportTaskSucceeded or ReportTaskFailed to report the result.

Use this mode when the workflow depends on a downstream consumer finishing its work before advancing.

To pass the task token to the event consumer, add a custom key in data that references $Context.Current.TaskToken:

Type: StateMachine
Name: MyCallbackWorkflow
SpecVersion: v1
StartAt: PutEventsAndWait
States:
  - Type: Task
    Name: PutEventsAndWait
    Action: EventBridge:PutEvents
    TaskMode: WaitForCustomCallback
    Parameters:
      id: xxxxx-xxxx-xxxx-xxxx
      type: aliyuncvc:MeetingEvent:MemberOperate
      eventBusName: fnf-eb-bus
      source: test-source
      data:
        taskToken: $Context.Current.TaskToken
        eventContent:
          key1: val1
          key2: val2
    End: true

The event consumer extracts the taskToken value from the event payload and calls ReportTaskSucceeded or ReportTaskFailed with that token to resume the workflow.