I'm trying to implement something like the model described in Figure 14 - Extended Pub-Sub .
I've looked at this snippet, which works fine. But when trying to implement the first part (i.e.: {pub, ...} -> {xsub
I don't receive any data on the xsub
socket.
The following code blocks forever, instead of receiving the message:
use zmq::{Context, SocketType::XSUB, PUB};
const ADDRESS_XSUB: &'static str = "tcp://127.0.0.1:9123";
fn main() {
let context = Context::new();
let xsubscriber = {
let socket = context.socket(XSUB).unwrap();
socket.bind(ADDRESS_XSUB).unwrap();
socket
};
let publisher = {
let context = Context::new();
let socket = context.socket(PUB).unwrap();
socket.connect(ADDRESS_XSUB).unwrap();
socket
};
publisher.send("", zmq::SNDMORE).unwrap();
publisher.send("HI", 0x00).unwrap();
assert_eq!(b"HI".as_ref(), &xsubscriber.recv_bytes(0).unwrap());
}