[zeromq-dev] Error handling in client code.

Theo Schlossnagle theo at omniti.com
Thu May 7 20:06:55 CEST 2009


On May 7, 2009, at 1:00 PM, Martin Sustrik wrote:

> Hi Theo,
>
>> I'm attempting to prototype an application using zeromq for   
>> interprocess messaging.  I have a C client and a Java Client.   
>> I've  got the code working, but I'm running into a wall with some  
>> of the  assertions in the code.
>> In my Java process, when I: Zmq zmq = new Zmq("localhost"); it  
>> works  fine when zmq_server is running.  However, when zmq_server  
>> isn't  running I don't seem to have an opportunity to robustly  
>> handle this  failure condition in my application -- it abort()s  
>> within JNI.  Much  to my surprise, I also get asserts in stead of  
>> errors for my client  code to compensate for.  What's the correct  
>> approach here?  I need to  able to robustly continue my application  
>> when zmq isn't around.
>
> The primary use case for 0MQ are distributed 24/7 applications. In  
> such an environment not having access to central repository of  
> services is as severe a problem as say not having operating system  
> installed. The idea is that the component asserts and gets  
> repetitively restarted by a watchdog process until it ultimately  
> succeeds to connect. Optionally, the watchdog process can send a red  
> emergency alert (email, SMS) to the admin.
>
> Other applications, however, where messaging is a nice-to-have  
> rather then a unconditionally-critical feature, would benefit from  
> soft error handling in this scenario.
>
> At the moment there are 2 possible solutions:
>
> 1. Tweak the code to return error instead of assertion.
> 2. Replace zmq_server-based name resolving by a dummy resolver. In  
> that case there'll be no need for zmq_server, but you'll have to  
> supply IP addresses/hostnames instead of symbolic names (say  
> "server001:5555" instead of "MyQueue" etc.)
>
> If you are interested in trying one of the two, I'll explain further.


I'm interested.  My interest in zeromq is not so much its performance,  
but its light weight relative to other solutions out there.  0MQ looks  
light and self contained and I really appreciate that over running  
something like RabbitMQ (which requires an erlang install) or ApacheMQ  
which requires a 44MB install. I also really don't need a lot of the  
features that either bring and the concept of zeromq seems to satisfy  
my basic requirements.

I'm not sure what I want here w.r.t. zeromq.  Here's the basic  
architecture of the app:

I have a long running process written in C (A) that pulls durable  
queues from multiple datacenters (aggregating metric and status  
data).  This process inserts data into a relational database for  
mining.  I'd also like this process to queue messages to a real-time  
event processing system (B) written in Java.  The Java process needs  
to be long running as well (as the event processing is based on  
context of data -- and if it restarts, it is an expensive process to  
restore context in the temporal stream of events.  So, if A goes done,  
I don't want B to assert and if B goes down I don't want A to assert.   
And if they use a broker (like zmq_server) I don't want a momentary  
disruption of that broker to cause those processes to stop.  Those  
processes already have extensive alerting mechanisms in them as that  
are mission critical.

I *think* I want (B) to have a global queue called "firehose" to which  
(A) sends events and (A) to have a global queue called "alerts" over  
which (B) returns a heavily filtered stream.

--
Theo Schlossnagle
http://omniti.com/is/theo-schlossnagle
p: +1.443.325.1357 x201   f: +1.410.872.4911








More information about the zeromq-dev mailing list