Konrad,

There is a similar case when using AbstractActorSubscriber.

I have defined an actor by deriving from AbstractActorSubscriber. This
actor also use WSClient to upload some data to the remote server.
I guess I should not let this actor  asynchronously execute its task, that
might give incorrect back-pressure information to the publisher, so I still
use CompletableFuture.get to block the actor's thread.

I think I should not stash messages in this case, that also give incorrect
information to the publisher. right?

Is there any way to not block actor's thread in this case?

Thanks for your help.

guofeng




On Mon, Apr 25, 2016 at 10:43 PM, Guofeng Zhang <guofen...@gmail.com> wrote:

> You are right, I use java.
>
> Following your instruction, I have done it well.
>
> Thanks!
>
> Guofeng
>
>
> On Sun, Apr 24, 2016 at 11:51 PM, Konrad Malawski <
> konrad.malaw...@lightbend.com> wrote:
>
>> I'm assuming you're using Java, please tell about this explicitly when
>> asking questions :-)
>>
>> CompletionStage<...> futureResponse = http client calls thingy
>> akka.pattern.PatternsCS.pipe(futureResponse,
>> context.dispatcher).to(self());
>> set a flag that you're waiting or become() into such state,
>> for all other messages than the piped one call stash().
>>
>> Read about stash, pipe and become in the documentation (search box will
>> help :-))
>>
>> http://doc.akka.io/docs/akka/2.4.4/java/untyped-actors.html#Ask__Send-And-Receive-Future
>>  etc
>>
>> --
>> Konrad `ktoso` Malawski
>> Akka <http://akka.io> @ Lightbend <http://lightbend.com>
>>
>> On 24 April 2016 at 17:45:29, Guofeng Zhang (guofen...@gmail.com) wrote:
>>
>> Hi,
>>
>> In an actor, I use WSClient (a class from playframework) to access remote
>> server, which returns a CompletionStage.
>>
>> For my case, the actor should not process next message before the
>> response is arrived and processed by the actor.
>>
>> Currently I use CompletableFuture.get() to block the actor's thread. I
>> know it is not better.
>>
>> Will it be possible for me to notify the actor to stop fetching messages
>> from its mailbox, then in some time later to notify it to work normally
>> (for example,at the completion time of the CompletableFuture) ?
>>
>> Or is there any best practice for my case?
>>
>> Thanks for your help.
>>
>> Guofeng
>>
>> --
>> >>>>>>>>>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>

-- 
>>>>>>>>>>      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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to