[rabbitmq-discuss] Network failures recovery with RabbitMQ Javaclient
simone.busoli at gmail.com
Fri Dec 9 21:16:11 GMT 2011
On Fri, Dec 9, 2011 at 17:13, Michael Klishin
<michael.s.klishin at gmail.com>wrote:
> Le 09/dic/2011 à 19:41, Busoli, Simone a écrit :
> > I'm dealing with this by having a single channel with one consumer which
> consumes from all the queues the application needs to read data from. What
> kind of limitation do you see in keeping it single threaded?
> I think it's fine for many cases, however, I am designing a solution that
> library will use and there are definitely problems that can be naturally
> split into many concurrent tasks.
> Currently both Langohr and Hot Bunnies use an executor (basically, submit
> message handlers to a thread pool) which is single threaded by default but
> can be swapped with any other. So my thinking is influenced by this
> scenario, probably too much.
I'm not familiar with the executor you mention, but with "submit message
handlers to a thread pool" what do you mean exactly? What I mentioned above
is just how the library consumes messages from rabbit, how it marshals them
to the application code is a different matter. Currently I'm doing the
marshaling in the same thread as that which consumes from the rabbit queue,
which has the disadvantage of being as blocking as the application code
which consumes the message, but also the advantage of being able to
intercept exceptions being thrown by the application consuming the message
and thus enable policies to retry the consume, for instance. Anyway I'm not
sure I understand what you specifically refer to and I'be glad if you could
expand as it is something interesting for me too, as I didn't take much
time to look into how other libraries are handling that.
> >> 3. How do I detect that reconnection has succeeded?
> > In the .NET client when you Open the connection and no exception is
> thrown I think you can safely assume that the connection has been
> This is true for the Java client, too. Does this mean that you open all
> channels in one place in the code? (I find this is a good idea)
I actually have an IPublishingModule and an IComsumingModule, which are
independent of each other. They both subscribe to events fired by a
ReliableConnection class I implemented which takes care of spotting
connection issues and schedule reconnection the broker when it shuts down,
notifying observers about these events. The modules carry out what is
sensible for them in response to connection status events. For instance the
publishing module stops trying to publish and enqueues publishes requested
by the application code (which is thus unaware, to a certain extent, of the
temporary connection failure), and then as soon as the connection is
restored recreates the channel and resumes publishing. On the other hand
the consuming module will just stop receiving and will recreate the amqp
entities when the connection is restored.
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss