Update PubSub Raw doc (#4659)

* Update pubsub-raw.md

Updating Raw PubSub doc to be more specific about content type and delivery details.

Signed-off-by: Alice Gibbons <alice@diagrid.io>

* Update daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-raw.md

Signed-off-by: Mark Fussell <markfussell@gmail.com>

---------

Signed-off-by: Alice Gibbons <alice@diagrid.io>
Signed-off-by: Mark Fussell <markfussell@gmail.com>
Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
Alice Gibbons 2025-05-24 07:32:37 +02:00 committed by GitHub
parent 46d200e751
commit 4638f8f3fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,7 @@ weight: 2200
description: "Learn when you might not use CloudEvents and how to disable them."
---
When adding Dapr to your application, some services may still need to communicate via pub/sub messages not encapsulated in CloudEvents, due to either compatibility reasons or some apps not using Dapr. These are referred to as "raw" pub/sub messages. Dapr enables apps to [publish and subscribe to raw events]({{< ref "pubsub-cloudevents.md#publishing-raw-messages" >}}) not wrapped in a CloudEvent for compatibility.
When adding Dapr to your application, some services may still need to communicate via pub/sub messages not encapsulated in CloudEvents, due to either compatibility reasons or some apps not using Dapr. These are referred to as "raw" pub/sub messages. Dapr enables apps to [publish and subscribe to raw events]({{< ref "pubsub-cloudevents.md#publishing-raw-messages" >}}) not wrapped in a CloudEvent for compatibility and to send data that is not JSON serializable.
## Publishing raw messages
@ -105,13 +105,15 @@ $app->run(function(\DI\FactoryInterface $factory) {
## Subscribing to raw messages
Dapr apps are also able to subscribe to raw events coming from existing pub/sub topics that do not use CloudEvent encapsulation.
Dapr apps can subscribe to raw messages from pub/sub topics, even if they werent published as CloudEvents. However, the subscribing Dapr process still wraps these raw messages in a CloudEvent before delivering them to the subscribing application.
<img src="/images/pubsub_subscribe_raw.png" alt="Diagram showing how to subscribe with Dapr when publisher does not use Dapr or CloudEvent" width=1000>
### Programmatically subscribe to raw events
When subscribing programmatically, add the additional metadata entry for `rawPayload` to allow the subscriber to receive a message that is not wrapped by a CloudEvent. For .NET, this metadata entry is called `isRawPayload`.
When subscribing programmatically, add the additional metadata entry for `rawPayload` to allow the subscriber to receive a message that is not wrapped by a CloudEvent. For .NET, this metadata entry is called `isRawPayload`.
When using raw payloads the message is always base64 encoded with content type `application/octet-stream`.
{{< tabs ".NET" "Python" "PHP" >}}
@ -242,4 +244,4 @@ scopes:
- Learn more about [publishing and subscribing messages]({{< ref pubsub-overview.md >}})
- List of [pub/sub components]({{< ref supported-pubsub >}})
- Read the [API reference]({{< ref pubsub_api.md >}})
- Read the .NET sample on how to [consume Kafka messages without CloudEvents](https://github.com/dapr/samples/pubsub-raw-payload)
- Read the .NET sample on how to [consume Kafka messages without CloudEvents](https://github.com/dapr/samples/pubsub-raw-payload)