Hello Björn,

Maybe instead I/we should update this 
(http://doc.akka.io/docs/akka/2.0.1/scala/transactors.html) to add a 
section about how to execute code once the transaction has been committed. 

It took me a while to find out that I had to use the Txn companion object.

In my use case, I have to execute some side effects once I know that the 
transaction has gone through (the side effect in question is cancelling a 
schedule). As I understand, I can't really do that in the normal atomic 
block as this can be retried any number of times by the STM logic. 

You could also make it more explicit in the doc that an actor can cancel a 
transaction by throwing an exception.

Cheers, 

Guillaume.


On Wednesday, January 15, 2014 4:08:27 PM UTC+2, Björn Antonsson wrote:
>
>  Hi Guillaume, 
>
> On Wednesday, 15 January 2014 at 11:07, Guillaume Belrose wrote:
>
> Hi all, 
>
> I think I found what the issue is (at least with the version of Akka I am 
> using which is 2.1.4).
>
> Instead of using the implicit txn object as mentioned in the migration 
> guide, I've used the companion object Txn which is imported from 
> scala.concurrent.stm.Txn
>
> So this actually seems to be a bug in the Akka documentation.
>
>
> Thanks for finding this and sharing your solution.
>
> Unfortunately the 1.3 to 2.0 migration guide won’t be updated since we 
> won’t publish another version of Akka 2.0.x.
>
> B/
>  
>
> Guillaume.
>
>
> On Friday, April 6, 2012 10:59:57 PM UTC+2, Jonas Bonér wrote:
>
> Best to ask on the scala-stm mailing list. 
>
> On Fri, Apr 6, 2012 at 6:50 PM, James <[email protected]> wrote:
>
> Hi,
>
> I'm trying to write some atomic operations that handle rollbacks.
> There doesn't seem to be much documentation about rollbacks, but I did
> find some afterCommit/afterRollback examples at the bottom of this
> page: 
> http://doc.akka.io/docs/akka/2.0/project/migration-guide-1.3.x-2.0.x.html
>
> Unfortunately, I can't even get this simple example to compile:
>
> package mypackage
> import scala.concurrent.stm._
> class MyClass {
>  def testRollback() = {
>    atomic { implicit txn =>
>      txn.afterRollback { status => System.out.println("Rolled back
> with status " + status) }
>    }
>  }
> }
>
> This fails to compile with the following error:
>
> method afterRollback in trait InTxnEnd cannot be accessed in
> scala.concurrent.stm.InTxn  Access to protected method afterRollback
> not permitted because enclosing class MyClass in package mypackage is
> not a subclass of trait InTxnEnd in package stm where target is
> defined
>
> I'm using scala 2.9.1 and akka 2.0 (dependencies on akka-actor and
> akka-agent).  Any idea what's wrong?
>
> Thanks,
> James
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/akka-user?hl=en.
>
>
>
>
> -- 
> Jonas Bonér
> CTO
> Typesafe - The software stack for applications that scale
> Phone: +46 733 777 123
> Twitter: @jboner
>
>  -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>
> -- 
> Björn Antonsson
> Typesafe <http://typesafe.com/> – Reactive Apps on the JVM
> twitter: @bantonsson <http://twitter.com/#!/bantonsson>
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to