Cloud Events Support
How-to · Applies to Brighter V10
What are CloudEvents?
CloudEvents is a CNCF specification for describing event data in a common, standardized way. Without a standard for metadata, each messaging framework uses its own set of metadata fields, making it difficult to write interoperable code that works across different messaging systems.
CloudEvents solves this problem by providing a specification that defines:
A standard set of metadata attributes for events
Multiple content modes (binary and structured)
Protocol bindings for various transport protocols
Brighter V10 provides full CloudEvents specification support, making it easy to build interoperable, event-driven systems.
Content Modes
CloudEvents can be transmitted in two modes, and Brighter supports both:
Binary-Mode (Recommended)
In binary-mode, CloudEvents attributes are mapped to protocol headers, and the event data is placed in the message body.
When to use binary mode:
The transport protocol supports headers (RabbitMQ, Kafka, AMQP)
You want efficient serialization
You want to inspect event metadata without deserializing the body
Example RabbitMQ message with binary CloudEvents:
Structured Content Mode
In structured mode, both CloudEvents attributes and data are placed in the message body as a JSON object.
When to use structured mode:
The transport has insufficient header support (AWS SNS/SQS)
You need to preserve all metadata in a single payload
The protocol doesn't support custom headers well
Example SNS/SQS message with structured CloudEvents:
Setting CloudEvents in Publication
CloudEvents properties are configured in the Publication when you register producers. The Publication is passed to your message mapper, which can access these properties.
Basic Publication with CloudEvents
Additional CloudEvents Properties
You can set additional CloudEvents properties in the Publication:
Using CloudEvents in Message Mappers
In V10, Brighter passes the Publication to your message mapper, giving you access to CloudEvents properties. However, most users won't need custom mappers anymore thanks to default message mappers.
Default Mappers Handle CloudEvents Automatically
Brighter V10 includes default message mappers that automatically handle CloudEvents:
JsonMessageMapper<T>: Uses binary mode CloudEvents (headers)CloudEventJsonMessageMapper<T>: Uses structured mode CloudEvents (JSON body)
If you're using default mappers (recommended), CloudEvents are handled automatically based on your Publication configuration.
Custom Mapper with CloudEvents
If you need a custom mapper (e.g., for transforms), you can access CloudEvents from the Publication:
CloudEvents Type for Message Routing
One powerful use of CloudEvents is content-based routing using the type attribute. This allows multiple message types on a single channel.
See Dynamic Message Deserialization for details on using CloudEvents type for routing.
Example:
OpenTelemetry Integration
CloudEvents includes extensions for distributed tracing that integrate with OpenTelemetry:
traceparent: W3C Trace Context propagation
tracestate: Vendor-specific trace information
Brighter automatically propagates OpenTelemetry trace context using CloudEvents distributed tracing extensions. See OpenTelemetry Integration for details.
Claim Check Pattern with DataRef
CloudEvents supports the DataRef extension for the Claim Check pattern, where large payloads are stored externally and only a reference is included in the message.
See Claim Check Pattern for more details.
Breaking Changes
When migrating to V10, be aware of these CloudEvents-related breaking changes:
Message ID: Changed from
GuidtostringCorrelation ID: Changed from
GuidtostringPublication passed to mapper: Message mappers now receive
Publicationparameter
See the V10 Migration Guide for complete migration instructions.
CloudEvents Best Practices
1. Choose the Right Content Mode
Use binary mode for protocols with header support (RabbitMQ, Kafka, Azure Service Bus)
Use structured mode for protocols with limited headers (AWS SNS/SQS)
Brighter selects the appropriate mode automatically based on the transport
2. Use Meaningful CloudEvents Type
The type attribute should follow reverse-DNS naming:
3. Include Source Context
The source should uniquely identify where the event originated:
4. Use Subject for Fine-Grained Routing
The subject provides additional context in the scope of the source:
5. Leverage Default Mappers
In most cases, use Brighter's default message mappers rather than implementing custom mappers:
Only create custom mappers when you need transform pipelines.
Further Reading
CloudEvents Primer - Introduction to CloudEvents
CloudEvents Specification - Full specification
CloudEvents Reference - The attribute tables and the per-transport matrix
Default Message Mappers - Using automatic message mapping
Dynamic Message Deserialization - Content-based routing with CloudEvents
OpenTelemetry Integration - Distributed tracing with CloudEvents
Claim Check Pattern - Large message handling with DataRef
Dapr CloudEvents - How Dapr uses CloudEvents
Last updated
Was this helpful?
