Re: [akka-user] Slow reactive-kafka consumer when running multiple streams

2018-02-13 Thread Kilic Ali-Firat
Hi, 

I did a lot of tried and in my case, the bottleneckness was the 
akka-streams-kafka version. It was not aligned to my kafka server version. 

You have a look also to field "receive.buffer.bytes" parameter, make some 
tests with differents values.

You also can have a look to your CPUs consumption and hardware use for your 
streams (maybe you have reach bandwith of your machine?)

Le mardi 13 février 2018 08:47:49 UTC+1, Tal Pressman a écrit :
>
> Hi,
>
> We have several streams in the same runtime and it works fine. We did, 
> however, have problems when trying _a lot_ of consumers (~100, iirc), and 
> ended up sharing.
>
> Tal
>
>
> On Tuesday, February 13, 2018 at 1:37:24 AM UTC+2, rrodseth wrote:
>>
>> Anyone else running more than one stream in a deployable? Surely the 
>> answer must be yes. Would love to know what the problem might be.
>>
>>
>> On Wed, Dec 27, 2017 at 10:02 AM, Harshit Patel  
>> wrote:
>>
>>> We have an application that uses reactive-kafka to consume messages from 
>>> a kafka topic, do some validations and transformations on the messages, and 
>>> then persist to two different datastores. We are using two different 
>>> reactive kafka consumer streams for each of the datastores, using different 
>>> consumer-group-ids. Each of the stream can be enabled/disabled via 
>>> configuration in the application. 
>>>
>>> When we run either one of the consumer streams, they seem to run fine 
>>> and are able to consume messages and keep up with the topic reasonably 
>>> well. But when both streams are run together, we see a pretty high latency 
>>> (4-5 minutes) and both consumers are unable to keep up with the messages 
>>> from the topic. We are publishing about 15 messages/minute to the 
>>> topic. We are making sure that both consumers are managing blocking where 
>>> applicable, and are using separate dedicated dispatchers for the same. 
>>>
>>> Any ideas what could be going on ?
>>>
>>> -- 
>>> >> 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.
>>>
>>
>>

-- 
>>  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.


Re: [akka-user] Message processed by Actors

2018-02-13 Thread Kilic Ali-Firat
Hi, 

I will make some tests with Stash trait, it can be a good solution in my 
use case.

Thanking for sharing your idea :) 

Le lundi 12 février 2018 19:13:53 UTC+1, Justin du coeur a écrit :
>
> On Mon, Feb 12, 2018 at 11:26 AM, Kilic Ali-Firat  > wrote:
>
>> Hi Akka team,
>>
>
> I'm not the Akka team, but...
>
>
>> case class Worker() extends Actor {
>>
>>
>>   trait Message
>>   case class M1(x : Int) extends Message
>>   case class M2(x : Int) extends Message
>>
>>
>>   trait Result
>>   case  Sucess(m : Message) extends Result
>>   case Failed(m : Message) extends Result 
>>
>>
>>   def processM1(m : M1) : Future[Result]
>>
>>
>>   def processM2(m : M2) : Future[Result]
>>
>>
>>   override def receive = {
>> case m : M1 => this.processM1(m) pipeTo sender()
>> case m : M2 => this.processM2(m) pipeTo sender()
>>   }
>> }
>>
>>
>>
>>
>> Imagine that mailbox of a worker *has 4 messages : M1, M2, M3, M4.*
>>
>> It will process the mailbox messages per message starting by M1, then M2, 
>> then M3 and finally M4. 
>>
>> My question about order processing is : Do an Actor wait the completion 
>> of current message before passing to the next one in the mailbox ?
>>
>
> Depends on your definitions.  Keep in mind that Akka is focused on 
> *synchronous* processing -- if the message processing is synchronous, then 
> yes, a given Actor will only process one at a time.
>
> The problem is, you're spawning off separate threads with those Futures.  
> Akka has no insight or control over those, so it doesn't and can't wait for 
> them to be finished.  That's why you are seeing the behavior that you are.
>  
>
>> If I'm a wrong, Does Akka have a mechanism to wait for the completion of 
>> current message processing before passing to the next one ?
>>
>
> I don't know of any built-in way to do this.  The pattern I usually see 
> (and have sometimes used myself) is to:
>
> * Mix the Stash trait in;
> * When I start processing, become() a different state that stash()es all 
> messages except the Result;
> * When processing finishes (once you've dealt with the Result), 
> unstashAll() and unbecome() back to the main state.
>
> So basically, it isn't "waiting", it's storing all of the received 
> messages off to the side in the interim, and them putting them back into 
> the mailbox when you're ready to continue.  You get an effect similar to 
> waiting, but without blocking anything.
>

-- 
>>  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.


Re: [akka-user] Akka Persistence and avoiding var in favor of context.become

2018-02-13 Thread Christopher Hunt
On Friday, 15 September 2017 16:41:42 UTC+10, Konrad Malawski wrote:
>
> I would recommend avoiding become with PersistentActors in general, it 
> gets very complex.
>

The Akka doc (1) suggests that the use of become should be fine. Are you 
able to expand on the complexity statement above?

I'd also like to continue using become with an existing actor that I'm 
attempting to make persistent. Unfortunately, Akka Typed isn't an option 
for me at present.

Thanks for any guidance.

Kind regards,
Christopher

(1) https://doc.akka.io/docs/akka/2.5.9/persistence.html?language=scala

-- 
>>  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.


Re: [akka-user] Akka Persistence and avoiding var in favor of context.become

2018-02-13 Thread Patrik Nordwall
You have to do the right become transitions in the replay of the events,
and when consuming snapshots. Especially the latter is very easy to get
wrong.

On Tue, Feb 13, 2018 at 10:23 AM, Christopher Hunt 
wrote:

> On Friday, 15 September 2017 16:41:42 UTC+10, Konrad Malawski wrote:
>>
>> I would recommend avoiding become with PersistentActors in general, it
>> gets very complex.
>>
>
> The Akka doc (1) suggests that the use of become should be fine. Are you
> able to expand on the complexity statement above?
>
> I'd also like to continue using become with an existing actor that I'm
> attempting to make persistent. Unfortunately, Akka Typed isn't an option
> for me at present.
>
> Thanks for any guidance.
>
> Kind regards,
> Christopher
>
> (1) https://doc.akka.io/docs/akka/2.5.9/persistence.html?language=scala
>
> --
> >> 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.
>



-- 

Patrik Nordwall
Akka Tech Lead
Lightbend  -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>  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.


Re: [akka-user] Akka Persistence and avoiding var in favor of context.become

2018-02-13 Thread Christopher Hunt


> On 13 Feb 2018, at 8:26 pm, Patrik Nordwall  wrote:
> 
> You have to do the right become transitions in the replay of the events, and 
> when consuming snapshots. Especially the latter is very easy to get wrong.
> 
Thanks Patrik, that shouldn’t be an issue for my use case. My states are 
unauthenticated/authenticated… and that’s it. The actor only becomes 
authenticated after receiving a message from the outside along with some 
validation. So, I’m comfortable moving into the unauthenticated state until 
receiveRecover is finished.

While receiveRecover is executing though, I presume that I’m going to have to 
store the current state in a var…? Here’s what I’ve started with:
override def receiveRecover: Receive = {
  case e: Event => context.become(unauthenticated(state(e)))
}
…but of course, there is no existing state…

receiveCommand will present a similar challenge.

Any advice?

Cheers,
-C

-- 
>>  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.


[akka-user] AKKA - JAVA

2018-02-13 Thread S SATHISH BABU
Hello, I am new to Akka. I want to learn to develop Distributed programs. I 
searched for tutorials but couldn't find anything proper. The Akka 
documentation is too dry and theoretical. Where can I find Akka 
implementation in Java tutorials?!

-- 
>>  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.


[akka-user] Re: AKKA - JAVA

2018-02-13 Thread Kilic Ali-Firat
Hi,

You can find many examples in java reading following page : 
https://developer.lightbend.com/guides/

Le mardi 13 février 2018 11:09:36 UTC+1, S SATHISH BABU a écrit :
>
> Hello, I am new to Akka. I want to learn to develop Distributed programs. 
> I searched for tutorials but couldn't find anything proper. The Akka 
> documentation is too dry and theoretical. Where can I find Akka 
> implementation in Java tutorials?!
>

-- 
>>  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.


[akka-user] Delay a gracefully shutdown when application shutdown hook has been detected

2018-02-13 Thread Kilic Ali-Firat
Hi, 

I'm working on a part of my Akka application which must gracefully shutdown 
when a shutdown hook has been detected. 

The use case of my question is in case of deployment while the application 
is making some tasks. In this specific case, we do want to delay the 
deployment until my actors have not finished their tasks. 

My application is composed by a ClusterGroup with a limited number of 
routees (worker actors). To make a graceful shutdown, I like idea in 
following article: 
http://letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2

Basically what I want to do is : 

   1. Create a Reaper as in the article, collected dead souls 
   2. A shutdown hook has been detected, send a PoisonPill to each actors 
   in my actor system (I have all the elements for that)
   3. When all worker actors has been killed with seeing PoisonPill 
   message, shutdown the actor system + the application (using System.exit or 
   something else)

My main problem is that I need a mechanism of Akka or Scala to wait (or to 
timeout) the termination of my worker actors. 

I'm using following code to detect that my application has been shutdown 
from an external signal : 


 scala.sys.addShutdownHook { 
// let actors finished their work, blocking call ?

}


For reader of this question, I'm using Akka 2.5.7 and Scala 2.11.11. 

Can I have advices for such use case ? I don't think that I'm only one to 
make such things so I'm listening all ideas :)

-- 
>>  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.


[akka-user] Source.queue with java sample

2018-02-13 Thread 薛永飞
I cannot find a Source.queue with  java sample,does anyone has? please!

-- 
>>  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.


Re: [akka-user] Source.queue with java sample

2018-02-13 Thread Konrad “ktoso” Malawski
Browse the docs :-)

https://doc.akka.io/japi/akka/current/akka/stream/javadsl/Source.html#queue-int-akka.stream.OverflowStrategy-



-- 
Cheers,
Konrad 'ktoso ' Malawski
Akka  @ Lightbend 

On February 13, 2018 at 13:48:41, 薛永飞 (siren...@gmail.com) wrote:

I cannot find a Source.queue with  java sample,does anyone has? please!
--
>> 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.


Re: [akka-user] Source.queue with java sample

2018-02-13 Thread 薛永飞
many thanks !
 But I think I hadn't  described clearly.
what I mean is that ,I want to receive the source from akka remote(which is 
located in another system)

app1 send data to app2 which is a akka stream system



On Tuesday, 13 February 2018 20:55:37 UTC+8, Konrad Malawski wrote:
>
> Browse the docs :-)
>
>
> https://doc.akka.io/japi/akka/current/akka/stream/javadsl/Source.html#queue-int-akka.stream.OverflowStrategy-
>  
>
>
> -- 
> Cheers,
> Konrad 'ktoso ' Malawski
> Akka  @ Lightbend 
>
> On February 13, 2018 at 13:48:41, 薛永飞 (sire...@gmail.com ) 
> wrote:
>
> I cannot find a Source.queue with  java sample,does anyone has? please!
> --
> >> 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.
>
>

-- 
>>  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.


Re: [akka-user] Source.queue with java sample

2018-02-13 Thread Konrad “ktoso” Malawski
If you’re talking about doing akka streams / reactive streams over the
network (seems you imply that by mentioning ‘on other system’),
then the queue is not going to give you what you want.

That pattern is however trivial with a new feature that we’re about to
release in the upcoming release of Akka 2.5.10, which are stream refs:
Here’s a preview of the docs:
https://doc.akka.io/docs/akka/snapshot/stream/stream-refs.html



-- 
Cheers,
Konrad 'ktoso ' Malawski
Akka  @ Lightbend 

On February 13, 2018 at 15:07:51, 薛永飞 (siren...@gmail.com) wrote:

many thanks !
 But I think I hadn't  described clearly.
what I mean is that ,I want to receive the source from akka remote(which is
located in another system)

app1 send data to app2 which is a akka stream system



On Tuesday, 13 February 2018 20:55:37 UTC+8, Konrad Malawski wrote:
>
> Browse the docs :-)
>
> https://doc.akka.io/japi/akka/current/akka/stream/javadsl/
> Source.html#queue-int-akka.stream.OverflowStrategy-
>
>
> --
> Cheers,
> Konrad 'ktoso ' Malawski
> Akka  @ Lightbend 
>
> On February 13, 2018 at 13:48:41, 薛永飞 (sire...@gmail.com) wrote:
>
> I cannot find a Source.queue with  java sample,does anyone has? please!
> --
> >> 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.
>
> --
>> 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.


Re: [akka-user] Akka typed - first impressions

2018-02-13 Thread 'Michal Borowiecki' via Akka User List
Hi Patrik,
Thanks for the latest snapshot. I've been trying to play around with akka 
typed by migrating the project I'm working on and previously I'd been stuck 
at implementing stashing. Now with the StashBuffer it got simple.
Overall I'm really happy. It took a lot of time but I managed to migrate 
and test the system (all written in java) and all seems good. It's over a 
dozen actors and > 100 different message types. Most of them I turned into 
mutable behaviors as typically they have a lot of state. On the few 
smallest ones, I tried out the immutable style. The integration with 
akka-streams and akka-http was straightforward but we're not using 
persistence or clustering in this project, so haven't played with those in 
their typed variants yet. Overall, the contracts between actors got move 
apparent now and I even found one bug where an actor ref to the wrong actor 
was being passed into a method in our old code.

Beside all the positives, there are really only 2 things that I struggled 
with, that I'd like to share:
* routers - to migrate our RoundRobinPool routers, I followed the example 
from your blog (the immutable variant). What caused me problems was how to 
implement broadcast. I ended up defining a parent Broadcast class that 
holds the actual message and then subclassed it for each router so as to 
also implement the interface that's the type-parameter of the target 
behavior. I don't currently see a way to remove this duplication, so I 
wonder if you can offer any better advice?
* testing - the docs suggest to subclass TestKit and use a @AfterClass 
method to shut it down, however, that didn't work. JUnit requires 
@BeforeClass and @AfterClass annotated methods to be static. I worked 
around this in 2 different ways depending on complexity of the test. If the 
test suite creates some actors in the @BeforeClass method, then I do not 
subclass TestKit but just create an instance of it in a static field and 
call the various methods on that instance, including shutdown from the 
@AfterClass. In tests that don't need a TestKit instance in their 
@BeforeClass initialization, I do extend TestKit for convenience and then 
simply never call shutdown on it. I haven't seen that cause any problems so 
far. 

Thanks again for all the hard work going into akka-typed. Hope to see the 
latest improvements come out in a release soon :-)

Cheers,
Michał


On Sunday, 4 February 2018 12:19:54 UTC, Tal Pressman wrote:
>
> Thanks!
> I switched my code over to the new version, and once I got past all the 
> Actor -> Behaviors changes everything seems to work very nicely.
>
> If you're interested, you can see the code here (it's part of a course, so 
> there isn't much code there ^_^ ): 
> https://github.com/talpr/nex-akka-workshop/tree/akka-snapshot-ask
>
> As I originally thought, the "actor ask" provides a nice API over 
> `spawnAdater`, but there are quite a few places where it is quite 
> restrictive. Specifically, things like this 
> 
>  
> where I need to combine several responses and then transform them before 
> sending the final response back (without having to process it in the 
> "current" actor). But this is just some points for thought, overall it's 
> really nice!
>
> Tal
>
>
>
> On Friday, February 2, 2018 at 7:37:05 PM UTC+2, Patrik Nordwall wrote:
>>
>> I have published a snapshot of latest Akka Typed progress if you would 
>> like to try it out. Version 2.5-20180202-18 in repo 
>> https://repo.akka.io/snapshots/
>> Latest documentation: 
>> https://doc.akka.io/docs/akka/snapshot/typed/index.html
>>
>> Cheers,
>> Patrik
>>
>>
>> On Tue, Jan 30, 2018 at 10:27 AM, Tal Pressman  wrote:
>>
>>> Hi Patrik,
>>>
>>> Thanks for pointing me at the actor-to-actor pull request - it seems 
>>> like it would be very useful in "pipe to self" use-cases. It makes me 
>>> wonder, though, if it wouldn't be possible to do something similar while 
>>> "piping" to other actors.
>>>
>>> In my experience (which admittedly, may not be representative), I have 
>>> found that I use pipeTo(sender) much more than pipeTo(self). The main 
>>> use-case where I see this is something like this:
>>>
>>>- "Client" actor sends a request to some "singleton" actor.
>>>- The "Singleton" actor routes the request to the appropriate 
>>>destination. There are a few variations on these actors - sometimes they 
>>>transform the requests/responses, sometimes they create child actors to 
>>>route the request to. The important thing is they *don't change 
>>>state/behavior* based on the response.
>>>- A single "request" flow can have several of these "singleton" 
>>>actors, each considering the previous one the "client".
>>>
>>> In such cases, I much prefer transforming the future and piping back to 
>>> the sender, as that keeps all the code in one 

Re: [akka-user] Akka Persistence and avoiding var in favor of context.become

2018-02-13 Thread Christopher Hunt


> On 13 Feb 2018, at 20:50, Christopher Hunt  wrote:
> 
> While receiveRecover is executing though, I presume that I’m going to have to 
> store the current state in a var…? Here’s what I’ve started with:
> override def receiveRecover: Receive = {
>   case e: Event => context.become(unauthenticated(state(e)))
> }
> …but of course, there is no existing state…
Just to tie this off for me, I’m going to use a var to build initial state 
during receiveRecover as there is no way to become a new receiveRecover. 

Cheers 
C

-- 
>>  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.


Re: [akka-user] Delay a gracefully shutdown when application shutdown hook has been detected

2018-02-13 Thread Patrik Nordwall
I think you can do that with Akka’s Coordinated Shutdown
https://doc.akka.io/docs/akka/current/actors.html#coordinated-shutdown

Register your task to one of the phases, instead of using jvm shutdown
hook. Coordinated Shutdown will be triggered by jvm exit.

/Patrik
tis 13 feb. 2018 kl. 12:52 skrev Kilic Ali-Firat :

> Hi,
>
> I'm working on a part of my Akka application which must gracefully
> shutdown when a shutdown hook has been detected.
>
> The use case of my question is in case of deployment while the application
> is making some tasks. In this specific case, we do want to delay the
> deployment until my actors have not finished their tasks.
>
> My application is composed by a ClusterGroup with a limited number of
> routees (worker actors). To make a graceful shutdown, I like idea in
> following article:
> http://letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2
>
> Basically what I want to do is :
>
>1. Create a Reaper as in the article, collected dead souls
>2. A shutdown hook has been detected, send a PoisonPill to each actors
>in my actor system (I have all the elements for that)
>3. When all worker actors has been killed with seeing PoisonPill
>message, shutdown the actor system + the application (using System.exit or
>something else)
>
> My main problem is that I need a mechanism of Akka or Scala to wait (or to
> timeout) the termination of my worker actors.
>
> I'm using following code to detect that my application has been shutdown
> from an external signal :
>
>
>  scala.sys.addShutdownHook {
> // let actors finished their work, blocking call ?
>
> }
>
>
> For reader of this question, I'm using Akka 2.5.7 and Scala 2.11.11.
>
> Can I have advices for such use case ? I don't think that I'm only one to
> make such things so I'm listening all ideas :)
>
> --
> >> 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.