Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

improved error handling/messages/timeouts

  • Loading branch information...
commit 7c4d8a8ec050458cfe8710b44cdf34fca0c924d0 1 parent 1726368
authored November 01, 2010
11  src/org/runa/swarmiji/client/client_core.clj
@@ -48,6 +48,13 @@
48 48
 	 (catch Exception e))))))
49 49
          ;no-op, this sevak-proxy should be aborted, thats it
50 50
 
  51
+(defn unserialized-response [response-obj-string]
  52
+  (try
  53
+    (read-string response-obj-string)
  54
+    (catch Exception e 
  55
+      (log-exception e (str "Read failed on " response-obj-string))
  56
+      {:exception (exception-name e) :stacktrace (stacktrace e) :status :error})))
  57
+
51 58
 (defn on-swarm [sevak-service & args]
52 59
   (let [sevak-start (ref (System/currentTimeMillis))
53 60
 	total-sevak-time (ref nil)
@@ -57,8 +64,8 @@
57 64
 	sevak-name (fn [] (sevak-name-from @sevak-data))
58 65
 	sevak-time (fn [] (time-on-server @sevak-data))
59 66
 	messaging-time (fn [] (- @total-sevak-time (sevak-time)))
60  
-	on-swarm-response (fn [response-object]
61  
-			    (dosync (ref-set sevak-data response-object))
  67
+	on-swarm-response (fn [response-object-string]
  68
+			    (dosync (ref-set sevak-data (unserialized-response response-object-string)))
62 69
 			     (do
63 70
 			       (dosync (ref-set total-sevak-time (- (System/currentTimeMillis) @sevak-start)))
64 71
 			       (if (and (swarmiji-diagnostics-mode?) (success?))
14  src/org/runa/swarmiji/mpi/transport.clj
@@ -29,13 +29,17 @@
29 29
   (let [chan (create-channel)
30 30
         consumer (consumer-for chan DEFAULT-EXCHANGE-NAME DEFAULT-EXCHANGE-TYPE return-q-name return-q-name)
31 31
         on-response (fn [msg]
32  
-                      (custom-handler (read-string msg))
33  
-                      (.queueDelete chan return-q-name)
34  
-                      (.close chan))
  32
+                      (with-swarmiji-bindings
  33
+                        (try
  34
+                          (custom-handler msg)
  35
+                          (finally
  36
+                           (.queueDelete chan return-q-name)
  37
+                           (.close chan)))))
35 38
         f (fn []
36 39
             (send-message-on-queue (queue-sevak-q-name) request-object)
37 40
             (on-response (delivery-from chan consumer)))]
38  
-    (log-message "[" (number-of-queued-tasks) "]: Dispatching request")
  41
+    (log-message "[" (number-of-queued-tasks) (futures-count)
  42
+                 "]: Dispatching request on " return-q-name)
39 43
     (medusa-future-thunk return-q-name f)
40 44
     {:channel chan :queue return-q-name :consumer consumer}))
41 45
 
@@ -72,4 +76,4 @@
72 76
 (defn init-rabbit []
73 77
   (log-message "Swarmiji: RabbitMQ host is" (queue-host))
74 78
   (init-rabbitmq-connection (queue-host) (queue-username) (queue-password))
75  
-  (start-retry-rabbit 10000))
  79
+  (start-retry-rabbit 10000))

0 notes on commit 7c4d8a8

Please sign in to comment.
Something went wrong with that request. Please try again.