dapr / dapr/java-sdk

How to specify type with metadata of pubsub?

Aperta
#772 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
300
Fork
230
Merge medio
5g 1h
PR unite (30g)
5

Descrizione

The CloudEvent spec says we can specify the `type` in the metadata. The SDK allows metadata customization when publishing an event as below
```java
Map metadata = new HashMap<>();
metadata.put("type", "com.test.user.created");
Mono result = client.publishEvent("pubsub", "inbox", payload, metadata);
result.block(Duration.ofSeconds(2));
```

But the `type` seems always be `com.dapr.event.sent`. I debug into the gRPC code down to protocol buffer`serializeStringMapTo` and I am pretty sure the `type` is correctly written to the sidecar via 50001.

Are there anything wrong here? And can I specify other metadata like `metadata.rawPayload`?

If I do a POST with curl, this works
```
curl -X POST http://myurl... -d {"specversion" : "1.0", "type" : "com.mytest", "source" : "testcloudeventspubsub", "subject" : "Cloud Events Test", "id" : "111111", "time" : "2021-08-02T09:00:00Z", "datacontenttype" : "application/cloudevents+json", "data" : {"orderId": "100"}}
```
So I guess this problem only occurs in gRPC. However, the SDK does not support HTTP for pub/sub, right?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.