[ASYNC-18] CompilerException attempting to perform a transaction inside go block Created: 15/Aug/13 Updated: 16/Aug/13 Resolved: 16/Aug/13
|Reporter:||Adam Wittenberg||Assignee:||Timothy Baldridge|
When setting up a transaction inside of a go block, receiving the following error:
CompilerException java.lang.RuntimeException: No such var: clojure.core/runInTransaction, compiling:(NO_SOURCE_PATH:2:8)
|Comment by Timothy Baldridge [ 16/Aug/13 9:08 AM ]|
There are two problems with the example given.
a) dosync wraps the body of the body of the transaction in a fn. Go block translation stops at fn boundaries. The same applies to doseq.
b) The bigger problem is that this example code is incorrect. A transaction body may executed multiple times in that case some messages received from the channel may be dropped.
Closing this issue as the examples are flawed. However I will recommend that you look into doing the takes outside of the transaction, and then using a function to execute the transaction outside the body of a go.