   (do
     (reset! messages-receive-chan (chan))
     (start-message-loop @messages-receive-chan)
+    (reset! messages-send-chan (chan))
+    (start-message-send-loop @messages-send-chan)
     (start-http-server!)
     (start-router! @messages-receive-chan)))
+
+(defn restart! []
+  (stop!)
+  (start!))
 
 (defn -main
   [& args]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def memory-log (atom []))

(defn logf [s]
  (swap! memory-log conj s))

(defn import-file [{:keys [content]}]
  (imp/dance-perfect-xml->data (imp/read-xml-string content)))

(def message-log (atom []))
(def message-send-log (atom []))

(defn message-dispatch [{:keys [topic payload sender]} out-chan]
  (match [topic payload]
         [:file/import xml]

      (message-dispatch msg @messages-send-chan)
      (recur))))

(defn start-message-send-loop [messages-send-chan]
  (go-loop []
    (when-let [msg (<! messages-send-chan)]
      (println (str "send message " msg))
      (swap! message-send-log conj msg)
      (chsk-send! (:id msg) (:message msg))
      (recur))))

;; TODO
;; - component?
;; - tests
(defn stop! []
  (do
    (close! @messages-receive-chan)
    (close! @messages-send-chan)
    (stop-http-server!)
    (stop-router!)))

