dapr / dapr/java-sdk

How to specify type with metadata of pubsub?

オープン
#772 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
300
フォーク
230
平均マージ
5日 1時間
マージ済み PR(30日)
5

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start at the Java SDK's publishEvent path and the gRPC serializeStringMapTo call described in the issue; reproduce the metadata type case against the sidecar on port 50001 and compare it with the working HTTP request. Done means determining whether gRPC preserves CloudEvent metadata and documenting or correcting the observed behavior, including the metadata.rawPayload question.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
grpc, java
領域
api, backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。