Pub-sub mode test in ZEROMQ

Source: Internet
Author: User

Because the company has the demand, the communication efficiency between the program modules has high demand. Prior to the company's communications components are ACTIVEMQ, according to the online published test results show that it is less efficient, and later considered ready to start using ZEROMQ in new projects. See a few days to find a relatively simple to use, but do not know how to use into our project, coupled with the project more anxious stranded, and chose to socketapi similar to the Boost library in the ASIO library, because I compare dishes, the recent test found a variety of pits!!! Various pits!!! (Use caution for new projects for children's shoes unfamiliar to ASIO)

And then recently began to look at Zeromq, found online demo program a lot, but the explanation is very few, so here record Test records, and urge themselves to finish. Official online has a good demo program, I do not post it out, to note that the demo is the latest version of Linux, so the source is best to download the latest, Windows on the compilation needs a little change.

ZEROMQ respected mode programming, the first kind of request answer nothing to say. In the second pub-sub mode, there is nothing in the server, there is a problem with the configuration interface of the client:

int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);

Parameter one: socket handle;

Parameter two: Socket mode, here because is the client, so is the subscription mode: Zmq_subscribe;

Parameter three: subscribe to keywords;

Parameter four: length of parameter three;

For parameter three, official documents:



The interface must show the call, otherwise it is not subscribed, and the test results are:
Char *filter = (argc > 1)? ARGV[1]: ""; rc = zmq_setsockopt (subscriber, Zmq_subscribe, filter, strlen (filter));
Do not filter, will subscribe to all information;

If
Filter = "Test";
Subscribe to "test" as the beginning of the information, the middle of the message will not receive the keyword, (!! Test, for the keywords in the Space "", Linux exactly match, Windows does not match correctly, pending scrutiny);

Here Pub-sub mode can be used in a one-to-many scenario. So the question is, where does the message for the client receiver start filtering? ZEROMQ claims that the fastest message middleware, guess not so silly all receive data, and then client filtering, test results show that is true, directly on the result:


By grasping the packet display, only the received information, appear in the capture results, then the efficiency problem does not have to worry about, Pub-sub mode can be used up, testing a variety of distributed mode behind the same no problem, zeromq praise a first.











Pub-sub mode test in ZEROMQ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.