Pub/Sub without CloudEvents

Dapr uses CloudEvents to provide additional context to the event payload, enabling features like:

  • 追踪
  • Deduplication by message Id
  • Content-type for proper deserialization of event’s data

For more information about CloudEvents, read the CloudEvents specification.

When adding Dapr to your application, some services may still need to communicate via raw pub/sub messages not encapsulated in CloudEvents. This may be for compatibility reasons, or because some apps are not using Dapr. Dapr enables apps to publish and subscribe to raw events that are not wrapped in a CloudEvent.

Warning

Dapr apps are able to publish raw events to pub/sub topics without CloudEvent encapsulation, for compatibility with non-Dapr apps.

To disable CloudEvent wrapping, set the metadata to as part of the publishing request. This allows subscribers to receive these messages without having to parse the CloudEvent schema.

Diagram showing how to subscribe with Dapr when publisher does not use Dapr or CloudEvent

When subscribing programmatically, add the additional metadata entry for so the Dapr sidecar automatically wraps the payloads into a CloudEvent that is compatible with current Dapr SDKs.

Subscription Custom Resources Definitions (CRDs) do not currently contain metadata attributes (issue #3225). At this time subscribing to raw events can only be done through programmatic subscriptions.