繁体   English   中英

如何使用 protobuf 二进制文件在 PUB/SUB ( ZeroMQ ) 中进行过滤?

[英]How to filter in PUB/SUB ( ZeroMQ ) with protobuf binaries?

我使用 Go、ZeroMQ 和 protobuf 来编写微服务。

带有PUB/SUB原型的 ZeroMQ。 ( Go 中的zmq4库)。 如何在带有二进制 protobuf 消息的SUB消息中使用过滤器?

例如我的原始消息:

语法 = "proto3";

message UserMessage {
    string userId = 1;
    string msg    = 2;
}

我想过滤具有userId值的SUB客户端的消息:

listener.SetSubscribe("42") // <-string not working.

我知道了:

listener.SetSubscribe( string( []byte{ 10, 2 } ) + "42" )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM