          (let [qname (misc/initialize-rabbitmq-structures ch command "nextbot" fsid)]
            (logging/info "starting consumer for" qname)
            (lb/qos ch 1)
-           (lcons/subscribe ch qname (partial handle-msg fs))))))))
+           (lcons/subscribe ch qname (mqhelper/make-handler (partial handle-msg fs)))))))))
 
 
 (defn worker-run-section

(def entry-is-file? (partial entry-is-type? "file"))


(defn handle-msg-get_permissions
  [fs ch {:keys [delivery-tag exchange routing-key] :as meta} ^bytes payload]
  (let [body (json/read-json (String. payload "UTF-8"))
        directory (:directory body)
        entries-with-permissions (get-permissions fs directory (:entries body))]

    (let [listdir-cmd (rk/routing-key-string-with-command routing-key "listdir")]
      (doseq [entry (filter (fn [entry]
                              (and (entry-is-directory? entry)
                                   (not (:error entry))))
                            entries-with-permissions)]
        (let [subdirectory-path (vfs/join fs [directory (:relpath entry)])]
          (println "publish listdir" subdirectory-path listdir-cmd)
          (lb/publish ch exchange listdir-cmd
                      (json/write-str {:path subdirectory-path})))))


    (lb/publish ch exchange (rk/routing-key-string-with-command routing-key "update_directory")
                (json/write-str (assoc body :entries entries-with-permissions)))

    (lb/ack ch delivery-tag)))


(defn handle-msg-listdir
  [fs ch {:keys [delivery-tag exchange routing-key] :as meta} ^bytes payload]
  (let [body (json/read-json (String. payload "UTF-8"))
        path (:path body)
        entries (vfs/cmd-listdir fs path)]
    (println "handle-msg-listdir" path)
    (lb/publish ch
                exchange
                (rk/routing-key-string-with-command routing-key "get_permissions")
                (json/write-str {:directory path :entries entries})))
  (lb/ack ch delivery-tag))


(defn publish-some-message



(def command->msg-handler
  {"listdir" simple-listdir
   "get_permissions" simple-get_permissions})


(defn build-handle-connection
