This topic describes how to use EventBridge to route event streams to ApsaraMQ for RocketMQ (Offset Reset) in real time to implement message distribution and consumption management in an event-driven architecture.
Prerequisites
Before you begin, make sure you have:
An activated EventBridge service with permissions granted to a Resource Access Management (RAM) user
An ApsaraMQ for RocketMQ 5.x instance or ApsaraMQ for RocketMQ 4.x instance
A topic on the RocketMQ 5.x instance or a topic on the RocketMQ 4.x instance
(Optional) Tags on the RocketMQ 5.x instance or tags on the RocketMQ 4.x instance
(Optional) A group on the RocketMQ 5.x instance or a group on the RocketMQ 4.x instance
Create an event stream
Step 1: Start the event stream wizard
Log on to the EventBridge console.
In the left-side navigation pane, click Event Streams.
In the top navigation bar, select a region and click Create Event Stream.
In the Create Event Stream panel, enter a Task Name and Description.
Step 2: Configure the source, filtering, and transformation
In the Source, Filtering, and Transformation steps, specify the event source, event filtering rule, and event transformation rule. Then, click Next Step.
For details on event transformation, see Use Function Compute to perform message cleansing.
Step 3: Configure the sink
In the Sink step, select ApsaraMQ for RocketMQ (Offset Reset) from the Service Type drop-down list and configure the following parameters.
| Parameter | Description | Example |
|---|---|---|
| Instance Type | The version of the ApsaraMQ for RocketMQ instance. Valid values: RocketMQ 4.x, RocketMQ 5.x. | RocketMQ 5.x |
| InstanceId | The ApsaraMQ for RocketMQ instance to which you want to route messages. | rmq-cn-77845\*\*\*\* |
| Topic | The topic on the ApsaraMQ for RocketMQ instance to which you want to route messages. See Value modes below. | Partial Event: $.data |
| Group | The group used to manage offsets on the ApsaraMQ for RocketMQ instance. See Value modes below. | Partial Event: $.data |
| ConsumeTimestamp | The timestamp that specifies when messages are consumed. See Value modes below. | Partial Event: $.data |
Value modes for Topic, Group, and ConsumeTimestamp
The Topic, Group, and ConsumeTimestamp parameters each support three value modes:
| Value mode | Behavior |
|---|---|
| Partial Event | Extract the value from an event field using a JSONPath expression, such as $.data. |
| Fixed Value | Enter a static value. All events use this value. |
| Template | Define custom content in the Variables and Template code editors to dynamically generate a value. |
Note: For the ConsumeTimestamp parameter, the Template mode uses the Variable and Template code editors.
Step 4: Configure retry and dead-letter queue settings
Specify the retry policy and dead-letter queue for the event stream. For more information, see Retry policies and dead-letter queues.
Step 5: Save the event stream
Click Save to create the event stream.
Verify the result
After the event stream starts processing events, verify that offset resets are applied correctly on the ApsaraMQ for RocketMQ instance:
Log on to the ApsaraMQ for RocketMQ console.
In the top navigation bar, select the region where the instance resides.
In the left-side navigation pane, click Instances.
On the Instances page, find the instance and click Details in the Actions column.
In the left-side navigation pane, click Topics, then click the topic name.
On the Topic Details page, click the Message Query tab.
Set the Query Method and Time Range parameters, then click Query.