0

我正在开发一个通过集群中的 kubemq 交互的微服务。当发送带有一些标签的查询响应(通过 GRPC 协议)时:

    err := client.NewResponse().
                    SetRequestId(query.Id).
                    SetResponseTo(query.ResponseTo).
                    SetExecutedAt(time.Now()).
                    SetMetadata("this is a response").
                    SetBody([]byte("got your query, you are good to go")).
                    SetTags(map[string]string{"key0":"val0","key1":"val1"}).
                    Send(ctx)

我发现我在接收者的响应中看不到它们:

    response, err := client.NewQuery().
        SetId("some-query-id").
        SetChannel(channel).
        SetMetadata("some-metadata").
        SetBody([]byte("hello kubemq - sending a query, please reply")).
        SetTimeout(1 *time.Second).
        Send(ctx)
    fmt.Println("Response Tags Received:",response.Tags)

输出显示:

Response Tags Received: map[]

所以 response.Tags 是空的。然后我看了一下官方查询示例https://github.com/kubemq-io/kubemq-go/blob/master/examples/rpc/query/main.go。注意它使用的是休息协议

    client, err := kubemq.NewClient(ctx,
        kubemq.WithUri("http://localhost:9090"),
        kubemq.WithClientId("test-query-client-id"),
        kubemq.WithTransportType(kubemq.TransportTypeRest))

在我为查询响应添加了一些标签之后(如本文的第一个代码所示),它在响应中正确显示了标签,但是当我将协议切换到 grpc 时:

        kubemq.WithAddress("localhost", 50000),
    //  kubemq.WithUri("http://localhost:9090"),
        kubemq.WithClientId("test-query-client-id"),
        kubemq.WithTransportType(kubemq.TransportTypeGRPC))
    //  kubemq.WithTransportType(kubemq.TransportTypeRest))

它开始停止在响应中显示标签。

我在这里做了一些更新的 kubemqgo 示例https://github.com/Aidamir/kubemq-go/tree/master/examples/rpc 说明了这个问题。有 2 个目录 query-tags-rest、query-tags-grpc 和 query 是我用作源的官方查询示例。客户端协议只有少量修改。请解释一下,为什么使用 grpc 时标签不发送?文档中可能缺少一些协议限制吗?

4

1 回答 1

0

这是一个错误,我发布了一个问题https://github.com/kubemq-io/kubemq-go/issues/7并很快得到修复。您必须更新到版本 1.3.3 以避免此问题。

于 2020-02-27T06:41:08.933 回答