[zeromq-dev] C++ Majordomo Pattern

Frank Hartmann soundart at gmx.net
Tue Mar 26 21:19:49 CET 2013


After reading the zguide - which I liked a lot! It sounds so easy:) - I 
am now trying to get into 0mq by playing with an example and modifying
it a bit and see how the changes influence things.

I have now problems with the C++ majordomo example: It seems to break
before I change anything.

My first try was using the debian/experimental packages: zmq.hpp was
missing, so I downloaded that file "lastest version" from the git web
interface. Compiling was now possible, but the the process simply hung
on my machine and never did do anything. tcpdump showed only few
messages flowing for a short time. My system is mostly debian wheezy
with g++ 4.7.2

My second try was compiling the 0mq code myself. I have now better
knowledge what I am using:

$ (cd libzmq && git show)
commit 01fef415753d00acca7200b60835fe4027adcdf6

$ (cd play/zguide/ && git show)
commit 4f79d323dc1051a87e7eb885672b558ff9c716b0

$ (cd cppzmq/ && git show)
commit b23297800389149ac37f19b7215fa4734d344998

Compiling was relativly easy. Linking showed an unresolved symbol, which
vanished after I added the 'rt' library to the linker. Using cmake I do:

add_executable(mdworker zguide/examples/C++/mdworker.cpp)
add_executable(mdbroker zguide/examples/C++/mdbroker.cpp)
add_executable(mdclient zguide/examples/C++/mdclient.cpp)

target_link_libraries(mdworker ${ZMQ_LIBRARY} rt)
target_link_libraries(mdbroker ${ZMQ_LIBRARY} rt)
target_link_libraries(mdclient ${ZMQ_LIBRARY} rt)

The behaviour is different too: the mdbroker stops with an assertion as
soon as I start the worker.

$ /home/frank/0mq/fake_install/bin/mdbroker -v
13-03-26 20:16:13 I: MDP broker/0.1.1 is active at tcp://*:5555
13-03-26 20:16:35 I: received message:
[006] MDPW01
[001] 01
[004] echo
mdbroker: /home/frank/0mq/build/play-prefix/src/play-project/zguide/examples/C++/mdbroker.cpp:233: worker* broker::worker_require(std::string): Assertion `identity.length()!=0' failed.

My ideas now: 

I am doing something wrong:

- Are the three versions 'ok' - do the versions of libzmq, zguide and
cppzmq fit together?

- Is there a special order required to start the pattern? I current do:

1. ${PREFIX}/bin/mdbroker -v
2. ${PREFIX}/bin/mdworker -v
3. ${PREFIX}/bin/mdclient -v

Or is the C++ API is somehow broken. Or the examples? Please help!

with kind regards

More information about the zeromq-dev mailing list