Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Interrupting an Akka thread under certain conditions to avoid memory consumption

$
0
0

Hope this question does make sense but been recently playing with Akka and bugging myself with something that seems trivial at first but may conflict the whole system.

What I’m trying to solve is that whenever an actor makes a call to another actor with a given timeout I’m 100% sure that if the timeout is triggered the response that is being computed underneath and no longer to be consumed won’t fit in memory and crash the whole system.

Would it be safe to, in case of a timeout, notify the underneath actor thread to stop that computation and all the subsequent calls? I will put some pseudocode to illustrate better.

        Patterns.ask(...)
            .onComplete(new OnComplete<Object> {
            @Override
            public void onComplete(Throwable failure, Object success) throws Throwable {
                // Interrupt Future<Object> (Patterns.ask() thread) in here?
            }
        }, ...);

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1362