mirror of https://github.com/dapr/docs.git
including .NET publisher example
Signed-off-by: Fernando Rocha <fernando@diagrid.io>
This commit is contained in:
parent
828c96b127
commit
bd9eb23110
|
@ -20,7 +20,7 @@ Not using CloudEvents disables support for tracing, event deduplication per mess
|
|||
|
||||
To disable CloudEvent wrapping, set the `rawPayload` metadata to `true` as part of the publishing request. This allows subscribers to receive these messages without having to parse the CloudEvent schema.
|
||||
|
||||
{{< tabs curl "Python SDK" "PHP SDK">}}
|
||||
{{< tabs curl ".NET" "Python SDK" "PHP SDK">}}
|
||||
|
||||
{{% codetab %}}
|
||||
```bash
|
||||
|
@ -28,6 +28,46 @@ curl -X "POST" http://localhost:3500/v1.0/publish/pubsub/TOPIC_A?metadata.rawPay
|
|||
```
|
||||
{{% /codetab %}}
|
||||
|
||||
{{% codetab %}}
|
||||
|
||||
```csharp
|
||||
using Dapr.Client;
|
||||
using Shared;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers().AddDapr();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapGet("/", () => "Publisher API");
|
||||
|
||||
app.MapPost("/publish", async (DaprClient daprClient) =>
|
||||
{
|
||||
var message = new Message(
|
||||
Guid.NewGuid().ToString(),
|
||||
$"Hello at {DateTime.UtcNow}",
|
||||
DateTime.UtcNow
|
||||
);
|
||||
|
||||
await daprClient.PublishEventAsync(
|
||||
"pubsub", // pubsub name
|
||||
"messages", // topic name
|
||||
message, // message data
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
{ "rawPayload", "true" },
|
||||
{ "content-type", "application/json" }
|
||||
}
|
||||
);
|
||||
|
||||
return Results.Ok(message);
|
||||
});
|
||||
|
||||
app.Run();
|
||||
```
|
||||
|
||||
{{% /codetab %}}
|
||||
|
||||
{{% codetab %}}
|
||||
```python
|
||||
from dapr.clients import DaprClient
|
||||
|
|
Loading…
Reference in New Issue