removing unecessary lines of code and moddifying verbiage around raw message subscriptions

Signed-off-by: Fernando Rocha <fernando@diagrid.io>
This commit is contained in:
Fernando Rocha 2025-02-05 12:31:19 -08:00
parent e98d40fd23
commit 9ad76c3c05
1 changed files with 3 additions and 8 deletions

View File

@ -32,15 +32,12 @@ curl -X "POST" http://localhost:3500/v1.0/publish/pubsub/TOPIC_A?metadata.rawPay
```csharp ```csharp
using Dapr.Client; using Dapr.Client;
using Shared;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddDapr(); builder.Services.AddControllers().AddDapr();
var app = builder.Build(); var app = builder.Build();
app.MapGet("/", () => "Publisher API");
app.MapPost("/publish", async (DaprClient daprClient) => app.MapPost("/publish", async (DaprClient daprClient) =>
{ {
var message = new Message( var message = new Message(
@ -114,7 +111,7 @@ Dapr apps are also able to subscribe to raw events coming from existing pub/sub
### Programmatically subscribe to raw events ### Programmatically subscribe to raw events
When subscribing programmatically, add the additional metadata entry for `rawPayload` - `isRawPayload` on .NET - so the Dapr sidecar automatically wraps the payloads into a CloudEvent that is compatible with current Dapr SDKs. 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`.
{{< tabs ".NET" "Python" "PHP" >}} {{< tabs ".NET" "Python" "PHP" >}}
@ -124,12 +121,9 @@ When subscribing programmatically, add the additional metadata entry for `rawPay
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var app = builder.Build(); var app = builder.Build();
app.MapGet("/", () => "Subscriber API");
app.MapGet("/dapr/subscribe", () => app.MapGet("/dapr/subscribe", () =>
{ {
var subscriptions = new[] var subscriptions = new[]
@ -141,7 +135,8 @@ app.MapGet("/dapr/subscribe", () =>
route = "/messages", route = "/messages",
metadata = new Dictionary<string, string> metadata = new Dictionary<string, string>
{ {
{ "isRawPayload", "true" } { "isRawPayload", "true" },
{ "content-type", "application/json" }
} }
} }
}; };