Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2013 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5552244 to your computer and use it in GitHub Desktop.
Save anonymous/5552244 to your computer and use it in GitHub Desktop.
(ns immutant.init
(:use cluster-example.core)
(:require [immutant.messaging :as messaging]
[immutant.daemons :as daemon]
[immutant.cache :as cache]
[immutant.util :as util])
)
(messaging/start "/queue/msg")
(def listener (messaging/listen "/queue/msg" #(println "received:" %)))
(def done (atom false))
(def counter-cache (cache/cache "counter-cache"
:mode :replicated
:seed {:counter 42}))
(defn start []
(reset! done false)
(loop [i (get counter-cache :counter 0)]
(Thread/sleep 1000)
(when-not @done
(println "sending:" i)
(messaging/publish "/queue/msg" i)
(cache/put counter-cache :counter i)
(recur (inc i)))))
(defn stop []
(reset! done true))
(daemon/daemonize "counter" start stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment