Created
May 10, 2013 03:41
-
-
Save anonymous/5552244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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