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

Viewed 363

I use Go, ZeroMQ, and protobuf to write a microservice.

ZeroMQ with a PUB/SUB archetype. (zmq4 lib in Go). How to use a filter in a SUB message with binary protobuf message?

For example my proto message:

syntax = "proto3";

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

I would like to filter the messages for a SUB client with a value of userId:

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

I got it:

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