Exceptions in handler function for consuming are catched and never shown

5 views
Skip to first unread message

Magnus Landerblom

unread,
Jan 16, 2018, 4:42:41 AM1/16/18
to clojure-rabbitmq
Hi, 

Trying out Langohr for a project and I'm wondering how I should handle exceptions that happens in my handler function. 

Example: 
(let [ch (lch/open (...)
      {queue-name' :queue} (lq/declare ch "" {:exclusive true :auto-delete true})
      handler (fn [ch {:keys [routing-key delivery-tag]} ^bytes payload]
                  (throw (RuntimeException. "Some error")))]
    (lq/bind ch queue-name' "amq.topic" {:routing-key ".........."})
    (lc/subscribe ch queue-name' handler {:block true :auto-ack false})))

What has happened to me a couple of times is that the code that runs inside the handler fails and an exception is thrown but it never shows up in the terminal. 
It looks like its catched somewhere and never printed. 
Can I get it printed or do I have to wrap the code in a try-catch and handle ack/nack for my self there?


Michael Klishin

unread,
Jan 16, 2018, 7:29:21 AM1/16/18
to clojure-...@googlegroups.com
Consumers are expected to handle their exceptions.

RabbitMQ Java client consumer dispatch pool will hand all unhandled
exceptions to a separate handler. Langohr doesn't have a way to registering them
but standard handlers don't do anything beyond logging.

A couple of relevant links:

 * Unhandled Exceptions in http://www.rabbitmq.com/api-guide.html


--
You received this message because you are subscribed to the Google Groups "clojure-rabbitmq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-rabbitmq+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Magnus Landerblom

unread,
Jan 16, 2018, 8:12:31 AM1/16/18
to clojure-...@googlegroups.com
Okay, thank you.


You received this message because you are subscribed to a topic in the Google Groups "clojure-rabbitmq" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure-rabbitmq/UjLexUFfdac/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure-rabbit...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages