This topic describes how to connect a custom event source to EventBridge in the EventBridge console.

Step 1: Create a custom event source

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, click the name of the target event bus.
  5. In the left-side navigation pane, click Event Sources.
  6. On the Event Sources page, click Add Event Source.
  7. In the Add Custom Event Source panel, set the Name and Description parameters, select Custom Application from the Event Provider drop-down list, and then click OK.

Step 2: Create an event rule

Notice The event targets that you want to configure for an event rule must reside in the same region as the event rule.
  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, click the name of the target event bus.
  5. In the left-side navigation pane, click Event Rules.
  6. In the left-side navigation pane, click Event Rules. On the Event Rules page, click Create Rule.
  7. Complete the Create Rule wizard.
    1. In the Configure Basic Info step, enter a rule name in the Name field and a rule description in the Description field, and click Next Step.
    2. In the Configure Event Pattern step, set the Event Source Type parameter to Custom Event Source, select the created custom event source from the Event Source drop-down list, specify an event pattern in the Event Pattern Content code editor, and then click Next Step.
    3. In the Configure Targets step, configure an event target. Then, click Create.
      Note You can configure a maximum of five event targets for an event rule.
      • Service Type: Click Message Service.
      • Queue: Select the queue that you created.
      • Message Content: Click Complete Event.

Step 3: Publish an event

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, find the event bus to which you want to publish an event and click Publish Event in the Operations column.
    Note You can publish events only to custom event buses in the EventBridge console.
  5. In the Publish Event to Custom Event Bus panel, select a custom event source from the Custom Event Source drop-down list, enter the event content in the Event Body code editor, and then click OK.
    For more information about the event parameters, see Overview.

Step 4: Verify the result

  1. Log on to the MNS console.
  2. In the left-side navigation pane, click Queues.
  3. In the top navigation bar, select a region.
  4. On the Queues page, find the queue and choose More > Send Messages in the Actions column.
  5. In the Receive Message section of the Quick Experience page, click Receive Message.

    The following sample code shows the content of the received event:

    {
        "datacontenttype":"application/json;charset=utf-8",
        "aliyunaccountid":"123456789098****",
        "data":{
            "result":"accomplished",
            "snapshotId":"s-bp1civqxj9bbvxqn****",
            "snapshotType":"user",
            "snapshotName":"cust38997127_hins16008704_20210118112203",
            "diskId":"d-bp11151k3ad3a8qn****",
            "startTime":"2021-01-18T03:22:08Z",
            "endTime":"2021-01-18T03:24:09Z"
        },
        "subject":"acs:ecs:cn-hangzhou:123456789098****:snapshot/s-bp1civqxj9bbvxqn****",
        "source":"acs.ecs",
        "type":"ecs:Snapshot:CreateSnapshotCompleted",
        "aliyunpublishtime":"2021-01-18T03:24:42.208Z",
        "specversion":"1.0",
        "aliyuneventbusname":"default",
        "id":"ea1dd7e0-3973-4626-91fa-bd09af40****",
        "time":"2021-01-18T11:24:09.212+08:00",
        "aliyunregionid":"cn-hangzhou",
        "aliyunpublishaddr":"172.25.XX.XX"
    }

Step 5: Delete the event rule

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, click the name of the target event bus.
  5. In the left-side navigation pane, click Event Rules.
  6. On the Event Rules page, find the event rule that you want to delete and click Delete in the Operations column.
  7. In the Note message, read the note and click OK.
  8. In the Verify Account Security dialog box, click Obtain Verification Code, enter the obtained verification code in the Verification Code field, and then click OK.

Step 6: Delete the custom event bus

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Bus page, find the custom event bus that you want to delete and click Delete in the Operations column.
  5. In the Note message, read the note and click OK.
  6. Optional:In the Verify Account Security dialog box, click Obtain Verification Code, enter the obtained verification code in the Verification Code field, and then click OK.
Notice Make sure that no event source is associated with the custom event bus that you want to delete. Otherwise, the custom event bus fails to be deleted, and the following error message is returned: An event source has been bound to the event bus. Delete the event source bound to the event bus or specify another event bus.