These are chat archives for petabridge/akka-bootcamp

12th
Apr 2015
Bartosz Sypytkowski
@Horusiath
Apr 12 2015 04:48
@horsdal PreRestart calls PostStop internally ;)
Christian Horsdal
@horsdal
Apr 12 2015 07:08
@Horusiath so adding a PreStart should suffice. And would be a better option than a PostStop in this case. Right?
Bartosz Sypytkowski
@Horusiath
Apr 12 2015 07:08
no
this is associated with actor lifecycle
prestart and post stop are called on underlying actor instance, which may be recycled in case of stopping/restarting a particular actor
when new actor incarnation is being created, it's PreStart method is called, and before it becomes stopped or restarted (it's destroyed in both cases) PostStop method is called
therefore if you had allocated some disposable resources inside an actor and don't dispose them on PostStop (or in Dispose method when actor implements IDisposable), they will never get released
Thomas Tomanek
@thomastomanek
Apr 12 2015 08:49
Hi all. I'm just going through the bootcamp now, which is really useful. I was wondering if there was a way to persist mailboxes and or stashed messages? Looking to use Akka where we need to take messages from RabbitMQ but then demultiplex them by 'business id' onto separate streams to be processed by the domain model. we're very single threaded at this point at the moment because we can't lose these messages, so we take off a single message from RMQ at a time and let it be processed before acking and doing the next one. Akka looks perfect for us, but we'd need to persist buffered/pending messages....
Bartosz Sypytkowski
@Horusiath
Apr 12 2015 09:29
@sadprofessor AFAIK .NET implementation of Akka doesn't support durable mailboxes at the moment (JVM does). Akka.Persistence could be used for your case, but it's still in early stage.
Roger Johansson
@rogeralsing
Apr 12 2015 10:20
durable mailboxes are obsoleted in favor for persistence in JVM
@sadprofessor can you ack individual messages in RabbitMQ? when using azure servicebus, you can dequeue a batch of messages, pass them to different actors and those actors can send an ack back when done, and the receiver of those acks can ack the azure servicebus messages
Roger Johansson
@rogeralsing
Apr 12 2015 10:29
@sadprofessor with azure sb its possible to do something along the lines of this: https://gist.github.com/rogeralsing/d250694198166c3e5b8d (this is just pseudo code, but you get the idea)
fetch a bunch of messages, send each message to a consistent hashing router that spreads messages based on business ID or something, if the actor is done with a message, it replies back and you can ack the MQ message
this way, you can spread load over multiple servers, never lose a message, and if using akka.cluster, you can add more machines for processing w/o touching a single line of code
Roger Johansson
@rogeralsing
Apr 12 2015 10:34
I'd guess that Rabbit can do something similar
Roger Johansson
@rogeralsing
Apr 12 2015 11:18
@sadprofessor I created a fully working example for Azure Servicebus, hopefully, it can be adapted to Rabbit w/o much effort.. https://gist.github.com/rogeralsing/d05e4b7cc64a3cfff3b8
Thomas Tomanek
@thomastomanek
Apr 12 2015 12:27
yikes, good response, thanks for that. I'll look into adapting that example to Rabbit. I wasn't keen on writing mailboxes to disk because of the obvious performance hit, so something like this would be much better
Christian Horsdal
@horsdal
Apr 12 2015 15:06
@Horusiath Thanks for clarifying. Would agree then that this diagram https://github.com/petabridge/akka-bootcamp/blob/master/src/Unit-1/lesson6/Images/lifecycle_methods.png from 1.6 is somewhat misleading?
From the code in ActorBase it is quite clear though - which is nice :smile:
Bartosz Sypytkowski
@Horusiath
Apr 12 2015 15:10
It simply focuses on top level method calls. I think that showing how PostStop is called by PreRestart could obscure this diagram
Christian Horsdal
@horsdal
Apr 12 2015 15:36
Hmm. It led me to believe the cycle was different from how it actually is. But then again, if other people do not read it the way I did it's no problem.
Arjen Smits
@Danthar
Apr 12 2015 20:30
@sadprofessor i'd be interested in knowing which library your using to communicate with RMQ. Especially if your going to explicitly ACK your messages.