Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Created October 6, 2014 14:16
Show Gist options
  • Save kornysietsma/3cc5ef3eba14f85dd9af to your computer and use it in GitHub Desktop.
Save kornysietsma/3cc5ef3eba14f85dd9af to your computer and use it in GitHub Desktop.
rabbitmq / langohr detecting changed topology attempt
(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