[rabbitmq-discuss] Callback - handleDelivery

Michael Klishin michael.s.klishin at gmail.com
Fri Feb 7 17:05:53 GMT 2014


2014-02-07 17:55 GMT+04:00 cw storm <cwstorm at gmail.com>:

> Not sure I understand.  "Make sure your code is prepared for that."  What
> do you mean by that.


You instantiate Connection and Channel in one thread (often the main
thread) but incoming messages
are dispatched from a different thread ("main loop" or "network I/O
thread") into a pool every connection
has.

You need to make sure that the objects used in handleDelivery are
initialized in a thread safe
manner (e.g. not lazily). A null pointer exception coming from
handleDelivery suggests the problem
is with one of the objects you use there.


> Also, if thread pool, will it close once the broker receive a "basicAck"?


If you did not provide a custom executor service to
ConnectionFactory#newConnection, it will be
shut down when connection is closed. Otherwise it's up to you to shut it
down on application
shutdown.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140207/04e1f503/attachment.html>


More information about the rabbitmq-discuss mailing list