'ZeroMQ pub sub filtering behavior

I'm new to ZeroMQ. Today I am trying the pub/sub pattern with NetMQ (the ZMQ library for .NET). I noticed some strange behavior (at least, to me!). I create a subscriber socket and subscribes to topic "12345". The publisher then publishes messages with topic "1234567890". The subscriber can receive the messages! That means, the filter does not compare the whole topic string, but only checks if the published topic "starts with" the subscribed topic. To confirm that, I changed the subscribed topic to "2345". And the subscriber did not receive the messages. If I change the publishing topic to "23456890" (while the subscribed topic is "2345"), then the messages come! I'd like to know, is that the normal behavior of the topic filter in ZeroMQ (and NetMQ)? Thank you very much!



Solution 1:[1]

Q : "...is that the normal behavior of the topic filter in ZeroMQ (and NetMQ)? "

A :
Welcome to the lands of Zen-of-Zero - YES, this is documented property of ZeroMQ implementation of ultra-fast TOPIC-filtering. It works this way since ever ( v2.1.1+, v3.+, v4.+ and most probably it will remain so due to its ultimate performance and scaling envelopes ).

Also be informed, that a similar approach was taken by Martin SUSTRIK, the ZeroMQ co-father, in foundations of nanomsg and it's ports and more recent breeds ( pynano, pynng et al ), so it could be called a de-facto industry best-practice, could it be not?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3666197