     queue-name))
 
 (defn run-with-connection
-  [filesystem]
-  (let [conn       (rmq/connect)
-        ch         (lch/open conn)
-        queue-name (initialize-rabbitmq-structures ch "extract_content" "nextbot" filesystem)]
+  [filesystem options]
+  (let [rmq-settings (rmq/settings-from (:amqp-url options))
+        conn         (do
+                       (logging/info "connecting to rabbitmq" (:amqp-url options) rmq-settings)
+                       (rmq/connect rmq-settings))
+        ch           (lch/open conn)
+        queue-name   (initialize-rabbitmq-structures ch "extract_content" "nextbot" filesystem)]
 
     ;; (lq/declare ch queue-name :exclusive false :auto-delete true)
     ;; (lq/bind    ch queue-name "nextbot")



(defn handle-command-for-filesystem
  [filesystem]
  (while true
    (try
      (run-with-connection filesystem)
      (catch Exception err
        (logging/error "got exception" err)
        (trace/print-stack-trace err)

        section (or (config inisection)
                    (die (str "section " inisection " missing in " iniconfig)))
        fscrawler-section (or (config "fscrawler") {})
        options {:max-size (Integer. (fscrawler-section "max_size")),
                 :amqp-url (get fscrawler-section "amqp_url" "amqp://localhost/%2f")}
        filesystems (trimmed-lines-from-string (section "filesystems"))]
    (when (zero? (count filesystems))
      (die (str "no filesystems defined in section " inisection " in " iniconfig)))
