[zeromq-dev] Error handling in client code.
Apps, John
john.apps at hp.com
Thu May 7 19:15:41 CEST 2009
Is it not possible to establish a (generic) condition handler which catches this kind of thing rather than having the program go south?
The high-level language wrapper that exists for OpenVMS does just this. All it does today is call a standard condition handler which simply signals the error, reports the "true" error, e.g., "connection refused" in the case of ZMQ_SERVER not being present and allows the abort to continue. It could do something a bit more robust.
Along the above lines I would be more than interested to learn a bit more about your option "1. Tweak the code to return error instead of assertion.".
One could start a lengthy debate on this whole topic and would -hopefully- finish by everyone agreeing to differ!
Cheers, John
---- John Apps | Hewlett-Packard | John.Apps at HP.com | +49 171 869 1813 ----
-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Martin Sustrik
Sent: Thursday, May 07, 2009 19:00
To: Theo Schlossnagle
Cc: zeromq-dev at lists.zeromq.org
Subject: Re: [zeromq-dev] Error handling in client code.
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.
Systematic solution of the issue - one that can be incorporated into the
official codebase - would require more design work. I can elaborate on
the use cases and prospective solutions if you are interested.
Regards.
Martin
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list