Details
-
Type:
Enhancement
-
Status:
Closed
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Release 1.2
-
Component/s: None
-
Labels:None
-
Approval:Ok
Description
Reported by richhickey, Jan 01, 2009
Route agent errors to a queue
Comment 1 by chouser, May 26, 2009
The attached patch allows agents to have an error-callback, which could be used to
route errors to one or more queues.
Example usage:
user=> (send-off (agent nil
:error-callback (fn [a es]
(.printStackTrace (first es))
(clear-agent-errors a)))
(fn f [_]
(Thread/sleep 1000)
(send-off *agent* f)))
#<Agent@5dd2b9b7: nil>
user=> (shutdown-agents)
nil
user=>
java.lang.RuntimeException: Error executing action user$eval__394$f__399@63d87b85
at clojure.lang.Agent$Action.execute(Agent.java:63)
at clojure.lang.Agent$Action.doRun(Agent.java:107)
at clojure.lang.Agent$Action.run(Agent.java:118)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.concurrent.RejectedExecutionException
at
java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
at clojure.lang.Agent$Action.execute(Agent.java:57)
... 5 more
error-callback.patch
3.9 KB Download
Converted from http://www.assembla.com/spaces/clojure/tickets/30
Attachments:
error-callback.patch - https://www.assembla.com/spaces/clojure/documents/dY6WBiw3er3R14eJe5aVNr/download/dY6WBiw3er3R14eJe5aVNr
agent-error-handler-v1.diff - https://www.assembla.com/spaces/clojure/documents/cwEwcA_RSr3RpIeJe5aVNr/download/cwEwcA_RSr3RpIeJe5aVNr