Created
October 6, 2014 14:16
-
-
Save kornysietsma/3cc5ef3eba14f85dd9af to your computer and use it in GitHub Desktop.
rabbitmq / langohr detecting changed topology attempt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn try-topology [conn fn] | |
(let [ch (lch/open conn)] | |
(try | |
(fn conn ch) | |
true | |
(catch IOException e | |
(when-not (instance? ShutdownSignalException (.getCause e)) | |
(throw (Exception. "Unexpected exception trying RabbitMQ operation" e))) | |
(let [reason (-> e .getCause .getReason)] | |
(when-not (instance? AMQP$Channel$Close reason) | |
(throw (Exception. (str "Unexpected reason trying RabbitMQ operation:" reason) e))) | |
(when-not (= 406 (.getReplyCode reason)) | |
(throw (Exception. (str "Unexpected reply code:" (.getReplyCode reason) " - " (.getReplyText reason)) e))) | |
false))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment