Alibaba EventBridge
Since Camel 4.23
Only producer is supported
The Alibaba Cloud EventBridge component allows you to publish CloudEvents to an EventBridge event bus.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-alibaba-eventbridge</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Alibaba EventBridge component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean |
Endpoint Options
The Alibaba EventBridge endpoint is configured using URI syntax:
alibaba-eventbridge:operation
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Allowed event sources and source-scoped event types per event bus. Supports multi-bus DSL (bussrc - type1,type2), single-bus shorthand (src - type1,type2), JSON string, or Map/List objects. | String | ||
EventBridge endpoint URL. Carries higher precedence than region based client initialization. | String | ||
Default event bus name. | String | ||
Default event source. | String | ||
Default event subject. | String | ||
Default event type. | String | ||
Required Alibaba Cloud region. | String | ||
When true, verifies that the target event bus exists in Alibaba Cloud EventBridge using listEventBuses before publishing. Also validates the CloudEvent source URI against the allowedEventSources whitelist when that option is set. | false | boolean | |
Validate CloudEvents 1.0 specification constraints on map fields. | true | boolean | |
When true, verifies that the CloudEvent event type is valid for the event source on the target event bus against Alibaba Cloud rule filter patterns before publishing. | false | boolean | |
TTL in milliseconds for caching event bus existence lookups per bus name. Applies only when validateEventSource is true. | 300000 | long | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Autowired Autowire an existing EventBridge client instance. | EventBridgeClient | ||
Access key for the cloud user. | String | ||
Secret key for the cloud user. | String | ||
Configuration object for cloud service authentication. | ServiceKeys |
Message Headers
The Alibaba EventBridge component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelAlibabaEventBridgeEventBusName (producer) Constant: | Event bus name override. | String | |
CamelAlibabaEventBridgeEventSource (producer) Constant: | Event source override. | String | |
CamelAlibabaEventBridgeEventType (producer) Constant: | Event type override. | String | |
CamelAlibabaEventBridgeEventSubject (producer) Constant: | Event subject override. | String | |
CamelAlibabaEventBridgeValidateEventSource (producer) Constant: | Validate event source against Alibaba Cloud EventBridge. | Boolean | |
CamelAlibabaEventBridgeValidateEventType (producer) Constant: | Validate event type against Alibaba Cloud EventBridge rule filter patterns. | Boolean | |
CamelAlibabaEventBridgeValidateEventSpec (producer) Constant: | Validate CloudEvents 1.0 specification constraints on map fields. | Boolean | |
CamelAlibabaEventBridgeAllowedEventSources (producer) Constant: | Allowed event sources and source-scoped event types per event bus (DSL string, JSON, Map, or List). | Object | |
CamelAlibabaEventBridgeEventSourceCacheTtl (producer) Constant: | TTL in milliseconds for cached bus event sources and types. | Long | |
CamelAlibabaEventBridgeRequestId (producer) Constant: | Alibaba Cloud request id. | String |
Usage
Message Headers and Properties
The component defines constants in package org.apache.camel.component.alibaba.eventbridge.constants:
-
AlibabaEventBridgeHeadersdefines all message header constants evaluated or set by the EventBridge producer. -
AlibabaEventBridgePropertiesextendsAlibabaEventBridgeHeadersand provides constants for Exchange properties (such asOPERATION), while inheriting all header constants.
Message headers evaluated by the EventBridge producer
Constant (AlibabaEventBridgeHeaders) | Header String | Type | Description |
|---|---|---|---|
|
|
| Event bus name to publish events to (overrides the endpoint option). |
|
|
| Event source URI (overrides the endpoint option). |
|
|
| Event type (overrides the endpoint option). |
|
|
| Event subject (overrides the endpoint option). |
|
|
| Whether to validate the event bus and event source against Alibaba Cloud. |
|
|
| Whether to validate the event type against Alibaba Cloud rule filter patterns for that source. |
|
|
| Whether to enforce CloudEvents 1.0 specification compliance checks (defaults to |
|
|
| Allowed event sources and source-scoped event types per bus (DSL string, JSON string, Map, or List). |
|
|
| Cache time-to-live in milliseconds for verified Alibaba Cloud event bus and type metadata (defaults to |
If any of the above headers are set, they will override their corresponding exchange property or query parameter value.
Event payload Map keys evaluated by the producer
When the message body is a Map (or List<Map> for publishing batch events), the producer validates and converts the Map into CloudEvents. Both Alibaba EventBridge dictionary keys and standard CloudEvents 1.0 specification keys are supported:
| Alibaba Key | CloudEvents Key | Type | Description |
|---|---|---|---|
| - |
| Target event bus name (overrides header or endpoint option). |
|
|
| Event source identifier (e.g., |
|
|
| Event type identifier (e.g., |
|
|
| Event subject / topic identifier. |
|
|
| Event payload data (serialized to JSON string if passed as a Map, POJO, or primitive). |
- |
|
| Unique event identifier (optional; auto-generated UUID if omitted). Cannot be blank if provided. |
- |
|
| Event timestamp in RFC 3339 / ISO-8601 format (e.g., |
- |
|
| CloudEvents specification version. Must be |
- |
|
| Media type of event data (e.g. |
- |
|
| URI identifying the schema that data adheres to. |
Event Validation and Caching
The component supports a 3-level hierarchical validation model: EventBus (N) → EventSources (N specific to that EventBus) → EventTypes (N specific to that EventSource)
Cloud Validation with Cache (validateEventSource and validateEventType):
-
Validated Cache Update Workflow: When validation is enabled, the component queries
listEventBusesandlistRuleson Alibaba Cloud EventBridge. -
Fail-Closed Semantics: If Alibaba Cloud API calls fail (network errors, permission errors, rate limits) or if target buses/rules are missing, validation fails closed immediately and throws an
IllegalArgumentExceptionto prevent unvalidated events from being published during outages. -
Prefix and Exact Match Rules: Rule
filterPattern`s are inspected for both exact match strings and prefix patterns ({"prefix": "…"}`) for both event sources and event types. -
Verified Cache Population: Only after cloud verification succeeds is the verified metadata stored in
EventSourceCachefor the configured TTL (defaults toeventSourceCacheTtl=300000, or per-message viaCamelAlibabaEventBridgeEventSourceCacheTtl).
Whitelist Validation (allowedEventSources):
-
Statically validates that the event bus, source URI, and event type in outgoing CloudEvents conform to a configured whitelist.
-
Restricts publishing to only authorized event sources and event types per event bus.
-
Supports single-bus shorthand, multi-bus DSL, JSON string format, and Java objects (
Map/List).
Security Considerations and Untrusted Ingress
| In Apache Camel’s security model, Camel message headers take precedence over endpoint URI options. When building routes that accept untrusted external ingress (such as HTTP endpoints, webhooks, or public messaging queues), external messages may carry To prevent untrusted callers from manipulating security policies, always sanitize or remove Camel headers before forwarding to the Alibaba EventBridge producer: |
Allowed Event Sources Configuration
The allowedEventSources option (and the CamelAlibabaEventBridgeAllowedEventSources header) allows you to define fine-grained whitelists for event buses, event sources, and source-scoped event types.
| Format | Description and Syntax |
|---|---|
Single-Bus Shorthand DSL | Configures allowed sources and types for the default event bus (or wildcard
|
Multi-Bus DSL | Scopes allowed event sources and event types per specific event bus:
|
JSON String Configuration | Defines hierarchical multi-bus or single-bus whitelists via JSON: * Multi-bus JSON structure: Top-level keys are event bus names, mapping to child objects of |
Java Objects / Registry | Programmatically configure using: * |
Single-Bus Configuration
When your route publishes to a single event bus (specified via eventBusName or endpoint URI), you can use the single-bus shorthand DSL or flat JSON format:
Shorthand DSL syntax:
acs:oss:cn-hangzhou:12345:my-bucket -> oss:ObjectCreated:PutObject, oss:ObjectCreated:PostObject; app.orders -> order:created:v1 In the endpoint URI (using RAW(…) to preserve special characters):
alibaba-eventbridge:putEvents?eventBusName=my-bus&allowedEventSources=RAW(acs:oss:cn-hangzhou:12345:my-bucket -> oss:ObjectCreated:PutObject, oss:ObjectCreated:PostObject; app.orders -> order:created:v1)®ion=cn-hangzhou&accessKey=RAW(ak)&secretKey=RAW(sk) Multi-Bus Configuration
When your route publishes events or batches spanning multiple distinct event buses, use the multi-bus DSL syntax to isolate permissions per bus:
Multi-Bus DSL syntax:
orders-bus[acs:oss:cn-hangzhou:12345:orders -> oss:ObjectCreated:PutObject; app.orders -> order:created:v1] | payments-bus[app.payments -> payment:authorized:v1, payment:captured:v1] Multi-Bus DSL Grammar and Components:
-
Bus Scopes: Each bus definition is enclosed in square brackets:
busName[…]. -
Bus Separator: Pipe (
|) separates multiple bus scope definitions. -
Source Separator: Semicolon (
;) separates multiple sources within a bus scope. -
Event Type Mapping: Arrow (
→) or equals (=) maps a source to its allowed comma-separated event types. Sources containing colons (such as URI ports or URNs) are supported without conflict. -
Wildcard Fallback: Use
*[…]to match any event bus not explicitly named. -
Omitted Types: If event types are omitted for a source (e.g.
orders-bus[app.orders]), any event type is permitted for that source.
In the endpoint URI:
alibaba-eventbridge:putEvents?allowedEventSources=RAW(orders-bus[acs:oss:cn-hangzhou:12345:orders -> oss:ObjectCreated:PutObject] | payments-bus[app.payments -> payment:captured:v1])®ion=cn-hangzhou&accessKey=RAW(ak)&secretKey=RAW(sk) If a message targeted for orders-bus attempts to use an event source configured only under payments-bus, validation fails with an IllegalArgumentException.
JSON Configuration
JSON configuration provides a clean, structured representation that is particularly well-suited for Spring Boot application.yml, Kubernetes ConfigMaps, or Camel JBang properties.
Multi-Bus JSON structure:
{
"orders-bus": {
"acs:oss:cn-hangzhou:12345:orders": [
"oss:ObjectCreated:PutObject",
"oss:ObjectCreated:PostObject"
],
"app.orders": [
"order:created:v1",
"order:cancelled:v1"
]
},
"payments-bus": {
"app.payments": [
"payment:authorized:v1",
"payment:captured:v1"
]
}
} Single-Bus flat JSON structure:
{
"acs:oss:cn-hangzhou:12345:my-bucket": [
"oss:ObjectCreated:PutObject",
"oss:ObjectCreated:PostObject"
],
"app.orders": [
"order:created:v1"
]
} In addition to JSON arrays, comma-separated strings are also supported for event types:
{
"app.orders": "order:created:v1, order:cancelled:v1"
} Response metadata in message body
The putEvents producer operation returns structured response metadata in the message body (Map<String, Object>):
| Key | Type | Description |
|---|---|---|
|
| Request identifier returned by EventBridge. |
|
| Resource owner account identifier. |
|
| Number of failed entries in the batch. |
|
| List of entry results, where each entry map contains |
Examples
Publish event with String / JSON body
from("direct:start")
.setBody(constant("{\"orderId\":\"123\"}"))
.to("alibaba-eventbridge:putEvents?eventBusName=my-bus&eventSource=camel.test&eventType=OrderCreated®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); Publish event with Map body (Alibaba Key Dictionary)
Map<String, Object> event = new HashMap<>();
event.put("eventBusName", "my-bus");
event.put("eventSource", "camel.test");
event.put("eventType", "OrderCreated");
event.put("eventSubject", "order/123");
event.put("eventData", Map.of("orderId", "123"));
from("direct:start")
.setBody(constant(event))
.to("alibaba-eventbridge:putEvents?region=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); Single-Bus Allowed Event Sources Validation
from("direct:start")
.setBody(constant(Map.of(
"eventBusName", "orders-bus",
"source", "acs:oss:cn-hangzhou:12345:my-bucket",
"type", "oss:ObjectCreated:PutObject",
"data", Map.of("file", "invoice.pdf")
)))
.to("alibaba-eventbridge:putEvents"
+ "?eventBusName=orders-bus"
+ "&allowedEventSources=RAW(acs:oss:cn-hangzhou:12345:my-bucket -> oss:ObjectCreated:PutObject, oss:ObjectCreated:PostObject; app.orders -> order:created:v1)"
+ "&validateEventSource=true&validateEventType=true"
+ "®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); Multi-Bus Allowed Event Sources Validation (Batch Publishing)
from("direct:start")
.setBody(constant(List.of(
Map.of("eventBusName", "orders-bus", "source", "acs:oss:cn-hangzhou:12345:orders", "type", "oss:ObjectCreated:PutObject", "data", Map.of("file", "image.jpg")),
Map.of("eventBusName", "payments-bus", "source", "app.payments", "type", "payment:captured:v1", "data", Map.of("amount", 100))
)))
.to("alibaba-eventbridge:putEvents"
+ "?allowedEventSources=RAW(orders-bus[acs:oss:cn-hangzhou:12345:orders -> oss:ObjectCreated:PutObject] | payments-bus[app.payments -> payment:captured:v1])"
+ "&validateEventSource=true&validateEventType=true"
+ "®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); JSON Configuration for Allowed Event Sources
String jsonConfig = """
{
"orders-bus": {
"acs:oss:cn-hangzhou:12345:orders": ["oss:ObjectCreated:PutObject", "oss:ObjectCreated:PostObject"],
"app.orders": ["order:created:v1"]
},
"payments-bus": {
"app.payments": ["payment:authorized:v1", "payment:captured:v1"]
}
}
""";
from("direct:start")
.setHeader(AlibabaEventBridgeHeaders.ALLOWED_EVENT_SOURCES, constant(jsonConfig))
.setBody(constant(Map.of(
"eventBusName", "orders-bus",
"source", "app.orders",
"type", "order:created:v1",
"data", Map.of("orderId", "ORD-12345")
)))
.to("alibaba-eventbridge:putEvents?region=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); Dynamic Header and Property Overrides
from("direct:start")
.setHeader(AlibabaEventBridgeHeaders.EVENT_BUS_NAME, constant("orders-bus"))
.setHeader(AlibabaEventBridgeHeaders.VALIDATE_EVENT_SOURCE, constant(true))
.setHeader(AlibabaEventBridgeHeaders.VALIDATE_EVENT_TYPE, constant(true))
.setHeader(AlibabaEventBridgeHeaders.ALLOWED_EVENT_SOURCES, constant("acs:oss:cn-hangzhou:12345:bucket -> oss:ObjectCreated:PutObject; app.orders -> order:created:v1"))
.setBody(constant("{\"orderId\":\"123\"}"))
.to("alibaba-eventbridge:putEvents?eventSource=app.orders&eventType=order:created:v1®ion=cn-hangzhou&accessKey=RAW(accessKey)&secretKey=RAW(secretKey)"); For more examples, see the unit tests in the camel-alibaba-eventbridge module.