[zeromq-dev] Just installed zmq and have a question about wiring and running a broker.
Martin Sustrik
sustrik at fastmq.com
Tue Apr 7 17:01:57 CEST 2009
Vineet Jain wrote:
>> Well, that's how it works currently. Have a look a chatroom example: There's
>> a chatroom application, say 100 display applications and 100 prompt
>
>
>
> Ok I'm confused now.
I would suggest reading this document:
http://www.zeromq.org/whitepapers:brokerless
or at least having a look at the pictures. That should make it clear. In
short: there are several messaging models and you should pick up one
that suits you the best.
> Lets take some psuedo-code as an example. If I
> have two python apps which generate logs. I want to extend these apps
> to push logs to a centralized messaging server so that an admin can
> view them when necessary.
>
> I have zmq_server running on 192.168.0.30
>
> python app1 (running on 192.168.0.31)
> Create an exchange on 192.168.0.30 if already not created. Add queue
> "logging_192.168.0.30" to the exchange on 192.168.0.30
> log messages to queue "logging_192.168.0.30"
>
> python app2 (running on 192.168.0.32)
> Create an exchange on 192.168.0.30 if already not created. Add queue
> "logging_192.168.0.31" to the exchange on 192.168.0.30
> log messages to queue "logging_192.168.0.31"
>
> admin client (running on 192.168.0.33)
> Connects to exchange on 192.168.0.30 and reads messages from the two
> queues "logging_192.168.0.30" and "logging_192.168.0.31"
Good. My preference would be to create a global_queue in admin_client
and let app1 and app2 bind to it (see p1.png).
> Corner cases:
> - If python app1 and python app2 both shut down and they have logged
> say 30 messages to the queue. Can the admin client program still
> retrieve the messages. This is a critical requirement for logging and
> why I would want to have a centralized server.
Sure. The queue would reside directly in admin_client process.
> - If the admin client program was not connected and the python app1
> and python app2 have logged messages to the two queues and for some
> reason they shutdown. Then the admin admin client connects to the
> zmq_server can it retrieve the messages that were sent to the queue
> before shutting down?
If you except your logger to go offline or crash (do you?) you have to
create a separate queue process (see p2.png). 'chatroom' application is
actually a queue process. You can use it straight away, just discard the
code that adds timestamps to the messages.
> - Is it possible to automatically discard messages to a q if there are
> no consumers setup?
Yes, that's the default. If there's no queue bound to an exchange,
messages are discarded.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p1.png
Type: image/png
Size: 8936 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090407/993bf944/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p2.png
Type: image/png
Size: 12757 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090407/993bf944/attachment-0001.png>
More information about the zeromq-dev
mailing list