All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Event transformation

Last Updated:Mar 11, 2026

EventBridge transforms events from the standard CloudEvents 1.0 format into the structure that an event target expects before routing them. Four transformation methods are available: Complete Event, Partial Event, Fixed Value, and Template.

How event transformation works

When an event rule routes an event to a target, EventBridge applies the specified transformation method. Each method controls what portion of the original event reaches the target and in what format:

MethodBehaviorWhen to use
Complete EventPasses the entire CloudEvents payload unchanged.The target accepts full CloudEvents payloads.
Partial EventExtracts a single field using a JSONPath expression.The target needs only one value from the event.
Fixed ValueSends a static value, ignoring event content. The event acts purely as a trigger.The target needs a constant payload regardless of event content.
TemplateExtracts fields into variables using JSONPath, then assembles a custom output from a template.The target requires a restructured payload.

Constraints

MethodConstraintLimit
Partial EventNumber of JSONPath expressions per transformation1
Partial EventExtracted value length10,240 characters
Fixed ValueValue length10,240 characters
TemplateVariable nestingNot supported
TemplateEach variable value length10,240 characters
TemplateTemplate length10,240 characters

Complete Event

The entire CloudEvents payload is routed to the target without modification.

Input event:

{
    "id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
    "source": "acs.oss",
    "specversion": "1.0",
    "type": "oss:ObjectCreated:PostObject",
    "datacontenttype": "application/json",
    "dataschema": "http://example.com/test.json",
    "subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
    "time": "2020-08-17T16:04:46.149Asia/Shanghai",
    "aliyuneventbusname": "demo-bus",
    "aliyunregionid": "Shanghai",
    "data": {
        "name": "test",
        "scope": 100
    }
}

Output: Identical to the input event. No fields are added, removed, or modified.

Partial Event

Extracts a single field from the CloudEvents payload using a JSONPath expression and routes only that value to the target.

Example: Extract the name field from the event data.

  • JSONPath expression: $.data.name

  • Input event data: {"name": "test", "scope": 100}

  • Output: test

Fixed Value

Routes a static value to the target, regardless of event content. The event serves only as a trigger.

Example:

  • Fixed value: test1

  • Output: test1

Regardless of the event content, the output is always the fixed value.

Template

Template transformation works in two steps:

  1. Define variables -- Use JSONPath expressions to extract values from the event and assign them to named variables.

  2. Write a template -- Reference the variables using ${variable_name} syntax to compose the output.

Step 1: Define variables

Map variable names to JSONPath expressions. Each expression extracts a value from the CloudEvents payload:

{
    "name": "$.data.name",
    "state": "$.data.state"
}

A variable value can also be a fixed string instead of a JSONPath expression:

{
    "name": "$.data.name",
    "constant": "Please deal with it timely."
}

Step 2: Write a template

Reference the defined variables in a template string or JSON structure using ${variable_name}:

The instance is broken, which name is ${name}, ${constant}

Output:

The instance is broken, which name is test, Please deal with it timely.

Template output formats

Templates support three output formats: simple string, simple JSON, and JSON with mixed types. The following examples all use this input event:

{
    "id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
    "source": "acs.oss",
    "specversion": "1.0",
    "type": "oss:ObjectCreated:PostObject",
    "datacontenttype": "application/json",
    "dataschema": "http://example.com/test.json",
    "subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
    "time": "2020-08-17T16:04:46.149Asia/Shanghai",
    "aliyuneventbusname": "demo-bus",
    "aliyunregionid": "Shanghai",
    "data": {
        "name": "test",
        "state": "RUNNING"
    }
}

With these variables defined:

{
    "name": "$.data.name",
    "state": "$.data.state"
}
FormatTemplateOutput
Simple string"name ${name} is in ${state}""name test is in RUNNING"
Simple JSON{"name": "${name}", "state": "${state}"}{"name": "test", "state": "RUNNING"}
JSON with variables and fixed values{"name": "${name}", "state": [9, "${state}", true], "Transformed": "Yes"}{"name": "test", "state": [9, "RUNNING", true], "Transformed": "Yes"}

Variables, static values, and mixed types (strings, numbers, booleans) can coexist in a single template.