Commits

Alvaro Videla  committed 281cb9b

fixes exchange declaration

  • Participants
  • Parent commits bda5d6d

Comments (0)

Files changed (2)

File src/resizer/core.clj

         [resizer.resizer :as rz]
         [resizer.fabric :as rf]))
 
-(def exchanges [
-                {:name "cloudstagram-broadcast-newimage" :type "fanout" :opts {:durable true}}
-                {:name "cloudstagram-new-image" :type "direct" :opts {:durable true}}
-                {:name "cloudstagram-upload" :type "direct" :opts {:durable true}}
-                ])
+(def exchanges [{:name "cloudstagram-broadcast-newimage" :type "fanout"}
+                {:name "cloudstagram-new-image" :type "direct"}
+                {:name "cloudstagram-upload" :type "direct"}])
 
-(defn -main []
+(defn -main
+  []
   (println "Connecting to Mongodb")
   (rz/mongo-connect)
   (println "Initializing Fabric")
   (rf/init-fabric exchanges)
   (println "Starting RabbitMQ Consumers")
-  (rc/start-consumer))
+  (rc/start-consumer)
+  (println "App Running"))

File src/resizer/fabric.clj

             [langohr.exchange :as lhe]
             [langohr.core :as lhc]))
 
-;; declare exchanges using with-open
-(defn rabbitmq-connect []
+(defn rabbitmq-connect
+  []
   (if (cf/cloudfoundry?)
     (lhc/connect (lhc/settings-from (cfrmq/url)))
     (lhc/connect)))
 
-(defn declare-exchange [ch exchange]
-  (let [{name :name type :type opts :opts} exchange]
-    (lhe/declare ch name type opts)))
+(defn declare-exchange
+  [ch exchange]
+  (let [{name :name type :type} exchange
+        declare-ok (lhe/declare ch name type :durable true)]
+    declare-ok))
 
-(defn init-fabric [exchanges]
-  (let [conn       (rabbitmq-connect)
-        ch         (.createChannel conn)]
-    (map declare-exchange ch exchanges)
+(defn init-fabric
+  [exchanges]
+  (let [conn (rabbitmq-connect)
+        ch   (.createChannel conn)]
+    (doseq [exchange exchanges]
+      (declare-exchange ch exchange))
     (.close ch)
     (.close conn)))