Regarding closing channel/connection... Using `with-open` macro might be a way better option than manually closing the channel and connection. `with-open` has a `let`-like form and automatically surrounds the expression in itself with a try-finally block, in which it pefrorms the closing for you. The object to be closed doesn't have to implement `java.io.Closable`, it just needs to have a .close() method on itself. Therefore it can be used for both `rmq/connect` connection (which is Closable) and for `lch/open` channel (it isn't Closable, but has .close() method). Here's an example: ``` (with-open [conn (rmq/connect) ch (lch/open conn)] (println "connection and channel open for 5 secs") (Thread/sleep 5000) (println "connection and channel will be closed even after exception") (throw (ex-info "boom!" {}))) ``` And here is what it macroexpands to: ``` (clojure.walk/macroexpand-all '(with-open [conn (rmq/connect) ch (lch/open conn)] (println "connection and channel open for 5 secs") (Thread/sleep 5000) (println "connection and channel will be closed even after exception") (throw (ex-info "boom!" {})))) ;; => (let* ;; [conn (rmq/connect)] ;; (try ;; (let* ;; [ch (lch/open conn)] ;; (try ;; (do ;; (println "connection and channel open for 5 secs") ;; (. Thread sleep 5000) ;; (println "connection and channel will be closed even after exception") ;; (throw (ex-info "boom!" {}))) ;; (finally (. ch clojure.core/close)))) ;; (finally (. conn clojure.core/close)))) ```
@@onthecodeagain Haven't used it in production myself but I heard from multiply developers of high load distributed systems complains about RabbitMQ and that it is hard to make Rabbit work reliably and as a result they switching to Kafka with no regrets :P Main point seems to be that Kafka is fast and has immutable message log that allows you to track bugs without pointing fingers at each other :D Besides, latest Kafka releases don't need Zookeeper (seems to be the biggest pain point). An CTO of e-comers chain said that they avoid big part of Kafka complexity by using singe partition per topic and singe provider per topic. This way you know who writes messages and they all ordered (order between partitions not guaranteed). Also *Redpanda* seems to be an interesting project.
@@eugenej.5584 I'll check out redpanda, I've never used Kafka before so have been doing a bit of research seems to be a nice alternate to RabbitMQ :) think it will make for a promising demo.