Blocking Transactions—Sensible Wait

A transaction may depend on a variable that’s expected to change, and the failure of the transaction may be temporary. As a response to that failure, we may return an error code and ask the transaction to retry after a delay. However, there’s no point repeating the request until another task has changed the dependent data. Akka gives us a simple facility, retry, which will roll back and block the transaction until one of the reference objects the transaction depends on changes or the configurable block timeout is exceeded. I like to call this a “sensible wait” because that sounds better than “blocking.” Let’s put blocking, I mean sensible wait, to use in an example in Java first and then in Scala.

Blocking ...

Get Programming Concurrency on the JVM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.