clojure - How to start immutant message queue? -
from immutant documentation @ http://immutant.org/documentation/current/apidoc/guide-installation.html:
with dependencies in place, invoke immutant services app’s main entry point, identified
:main
key inproject.clj
.
immutant's web service can invoked like:
(ns my-app.handler ... (:require [immutant.web :as web]) ... ) (def app ... ) (defn -main [& args] (web/run app))
what's equivalent of (web/run app)
immutant.messaging
?
here answer start queue
(ns my-project.name (:require [immutant.messaging :as msg])) (defn call-fn [args] (let [fun (ns-resolve "namespace fun defined" (symbol (first args))) params (rest args)] (if (seq params) (apply fun ) (fun)))) (msg/start "queue") (msg/respond "queue" (fn [args] (call-fn args)))
to call queue say
@(msg/request "queue" ["fun-name" params])
Comments
Post a Comment