Patterns.gracefulStop - This doesn't seem to work

68 views
Skip to first unread message

Boney Sekh

unread,
Apr 16, 2014, 1:55:59 AM4/16/14
to akka...@googlegroups.com
Hi,

I have been trying to use the Patterns.gracefulStop to stop an actor gracefully. I know my internal actor is stopped by verifying the postStop method is invoked.
However, the future is not returning true and is held until timeout.

Is there a bug?

Here is my code:

public class TestActor extends UntypedActor {

    private final Logger log = LoggerFactory.getLogger(TestActor.class);

    final ActorRef target;

    public TestActor( ActorRef target ) {
        this.target = target;
    }

    @Override
    public void postStop() throws Exception {
        super.postStop();
        log.info("Actor stopped...");
    }

    @Override
    public void onReceive( Object msg ) {
        if ( msg == Command.STOP_PROCESSING ) {
            log.info("Stopping actor...");
            getContext().stop( getSelf() );
        } else {
            unhandled(msg);
        }
    }

}


Code to stop:

Future< Boolean > stopped = Patterns.gracefulStop( actorRef, Duration.create( 5, TimeUnit.SECONDS ), Command.STOP_PROCESSING );
Await.result( stopped, Duration.Inf() );

Boney Sekh

unread,
Apr 16, 2014, 4:59:41 AM4/16/14
to akka...@googlegroups.com
Hi,

I thought I should add this. Basically this works when my TestActor is at the system level, i.e. system.actorOf. However what I am trying to do is to stop an actor which is a child of another.

Thanks,
B

√iktor Ҡlang

unread,
Apr 16, 2014, 5:24:52 AM4/16/14
to Akka User List
Hi Boney,

can you create a _minimized_ code sample that is self contained and shows the perceived bug?


--
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

Boney Sekh

unread,
Apr 16, 2014, 9:54:22 AM4/16/14
to akka...@googlegroups.com
Hi Victor,

Thanks for your reply. While I was trying to create the sample, I realized the problem was that I was using TestActorRef and that was probably the reason. When I moved my test to using JavaTestKit, it worked fine. Your reply helped me to get to the problem and thanks for that.

Regards,
Boney

√iktor Ҡlang

unread,
Apr 16, 2014, 10:03:23 AM4/16/14
to Akka User List
You're most welcome.

Happy hAkking!
Reply all
Reply to author
Forward
0 new messages