How to start immutant message queue?

165 Views Asked by At

From the immutant documentation at http://immutant.org/documentation/current/apidoc/guide-installation.html:

With the dependencies in place, you simply invoke the Immutant services from your app’s main entry point, identified by the :main key in your project.clj.

Immutant's web service can be invoked like:

(ns my-app.handler
  ...
  (:require [immutant.web :as web])
  ... )

(def app ... )

(defn -main [& args]
  (web/run app))

What's the equivalent of (web/run app) for immutant.messaging?

1

There are 1 best solutions below

0
On

here your answer to start queue

(ns my-project.name
(:require [immutant.messaging :as msg]))

(defn call-fn
  [args]
  (let [fun (ns-resolve "namespace where 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 the queue just say

@(msg/request "queue" ["fun-name" params])