Permalink
Browse files

changed wireformat to use clojure strings, added postal submodule for…

… emailing errors
  • Loading branch information...
amitrathore committed Aug 19, 2009
1 parent fbbe38b commit d0ebffe1598f72dec07b56bef338bd215d1ade3f
View
@@ -4,3 +4,6 @@
[submodule "lib/clojure/clj-utils"]
path = lib/clojure/clj-utils
url = git://github.com/amitrathore/clj-utils.git
+[submodule "lib/clojure/postal"]
+ path = lib/clojure/postal
+ url = git://github.com/drewr/postal.git
View
@@ -30,7 +30,7 @@ echo "SWARMIJI_HOME is ${SWARMIJI_HOME}"
echo "SWARMIJI_ENV is ${SWARMIJI_ENV}"
swarmiji_jars="${SWARMIJI_HOME}/lib/java"
-swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/:${SWARMIJI_HOME}/lib/clojure/clj-utils/src/"
+swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/:${SWARMIJI_HOME}/lib/clojure/clj-utils/src/:${SWARMIJI_HOME}/lib/clojure/postal/src/clj/"
clj_cp="."
[ -f /etc/clojure.conf ] && . /etc/clojure.conf
Submodule clj-utils updated 1 files
+4 −5 src/org/rathore/amit/utils/rabbitmq.clj
Submodule postal added at ee9c7a
View
Binary file not shown.
View
Binary file not shown.
@@ -4,15 +4,17 @@
(:use [org.runa.swarmiji.config.system-config])
(:use [org.rathore.amit.utils.config])
(:use [org.rathore.amit.utils.logger])
+ (:use [org.rathore.amit.utils.clojure])
(:use [org.runa.swarmiji.monitor.control_message :as control-message])
(:import (java.sql Date Time)))
(defn timestamp-for-sql [time-in-millis]
(str (.toString (Date. time-in-millis)) " " (.toString (Time. time-in-millis))))
-(defn persist-message [control-message]
- (log-message "control-message:" control-message)
- (let [now (timestamp-for-sql (System/currentTimeMillis))
+(defn persist-message [control-message-str]
+ (let [control-message (read-clojure-str control-message-str)
+ _ (log-message "control-message:" control-message)
+ now (timestamp-for-sql (System/currentTimeMillis))
with-timestamps (merge {:created_at now :updated_at now} control-message)]
(control-message/insert with-timestamps)))
@@ -2,7 +2,6 @@
(:import (com.rabbitmq.client Channel Connection ConnectionFactory QueueingConsumer)))
(use 'org.runa.swarmiji.mpi.transport)
-;(require '(org.danlarkin [json :as json]))
(use 'org.runa.swarmiji.config.system-config)
(use 'org.runa.swarmiji.utils.general-utils)
(use 'org.runa.swarmiji.sevak.bindings)
@@ -40,8 +39,8 @@
{:connection conn :channel chan :queue return-q-name}))
(defn new-proxy [sevak-service args callback-function]
- (let [request-json-object (sevak-queue-message sevak-service args)
- return-q-name (request-json-object :return-queue-name)]
- (send-message-on-queue (queue-sevak-q-name) request-json-object)
+ (let [request-object (sevak-queue-message sevak-service args)
+ return-q-name (request-object :return-queue-name)]
+ (send-message-on-queue (queue-sevak-q-name) request-object)
(register-callback return-q-name callback-function)))
@@ -4,7 +4,7 @@
(use 'org.rathore.amit.utils.rabbitmq)
(defn send-message-on-queue [q-name q-message-object]
- (send-on-transport-amqp (queue-host) (queue-username) (queue-password) q-name q-message-object))
+ (send-on-transport-amqp (queue-host) (queue-username) (queue-password) q-name (str q-message-object)))
(defn start-handler-on-queue [q-name handler-function]
(start-queue-message-handler-for-function-amqp (queue-host) (queue-username) (queue-password) q-name handler-function))
@@ -42,10 +42,11 @@
(handle-sevak-request service-handler service-args))]
(send-message-on-queue return-q response)))
-(defn sevak-request-handling-listener [req]
+(defn sevak-request-handling-listener [req-str]
(with-swarmiji-bindings
(try
- (let [_ (log-message "got request" req)
+ (let [req (read-clojure-str req-str)
+ _ (log-message "got request" req)
service-name (req :sevak-service-name) service-args (req :sevak-service-args) return-q (req :return-queue-name)
service-handler (@sevaks (keyword service-name))
sevak-agent (agent service-handler)]

0 comments on commit d0ebffe

Please sign in to comment.