Thread interrupt during message send

155 views
Skip to first unread message

hbf

unread,
Feb 19, 2016, 12:45:42 AM2/19/16
to Akka User List
Hi everybody,

If a thread gets interrupted during a actor.tell(msg, sender), is it guaranteed that the message still gets sent?

In my test case, the actor probe confirms that the message is indeed sent but having read that there are minor differences between the dispatcher used for tests and the "real" one, I'd like to confirm this.

Thanks!
Hbf

[ERROR] [02/18/2016 21:39:03.400] [Thread-3] [akka://default/system/testProbe-2] interrupted during message send
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(AbstractQueuedSynchronizer.java:1245)
at java.util.concurrent.locks.ReentrantLock.tryLock(ReentrantLock.java:442)
at akka.testkit.CallingThreadDispatcher.runQueue(CallingThreadDispatcher.scala:275)
at akka.testkit.CallingThreadDispatcher.dispatch(CallingThreadDispatcher.scala:208)
at akka.actor.dungeon.Dispatch$class.sendMessage(Dispatch.scala:132)
at akka.actor.ActorCell.sendMessage(ActorCell.scala:374)
at akka.actor.Cell$class.sendMessage(ActorCell.scala:295)
at akka.actor.ActorCell.sendMessage(ActorCell.scala:374)
at akka.actor.RepointableActorRef.$bang(RepointableActorRef.scala:169)
at akka.actor.ActorRef.tell(ActorRef.scala:128)
at org.foo.lambda$run$3(Bar.java:62)
at java.util.Optional.ifPresent(Optional.java:159)
at org.foo.run(Bar.java:57)



Roland Kuhn

unread,
Feb 19, 2016, 3:25:36 AM2/19/16
to akka-user
Hi Hbf,

(which is a bit funny because I always read «Hauptbahnhof» :-) )

there are no guarantees, we only promise at-most-once messaging. That said, local message sends are hard to drop without killing the JVM in the process. But interrupting threads may result in undefined behavior (in particular the interrupt and/or the message may get lost, depending on the mailbox and dispatcher implementations).

May I ask why you intend to interrupt Actor threads?

Regards,

Roland

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> 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 akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn


hbf

unread,
Mar 5, 2016, 8:27:52 PM3/5/16
to Akka User List

On Friday, February 19, 2016 at 12:25:36 AM UTC-8, rkuhn wrote:
Hi Hbf,

(which is a bit funny because I always read «Hauptbahnhof» :-) )

I can imagine :)

 
there are no guarantees, we only promise at-most-once messaging. That said, local message sends are hard to drop without killing the JVM in the process. But interrupting threads may result in undefined behavior (in particular the interrupt and/or the message may get lost, depending on the mailbox and dispatcher implementations).

Thanks for explaining in detail!
 
May I ask why you intend to interrupt Actor threads?

I am callling a legacy API which is blocking and can only get stopped via interruption. The exception I posted happened during a unit test.

There's hope I can abandon that API soon, so I think it's all fine.

Thanks!
Hbf
Reply all
Reply to author
Forward
0 new messages