These are chat archives for petabridge/akka-bootcamp

6th
May 2015
Gary Ewan Park
@gep13
May 06 2015 07:13
Hey, just getting started with the Akka.net Bootcamp, which I think is a really great idea.
Quick question, just to cement my understanding...
the "start" and "continue" messages that are passed into the .Tell(), are they "magic strings"?
i.e. to instruct the Actor to start and continue? there is no specific handling for these messages, like there is for the "read" command, so just wanted to make sure I wasn't missing something
thanks!
Arjen Smits
@Danthar
May 06 2015 07:16
@gep13 No they are not
Not sure which lesson you are specifically referring to (would help if you tell me, so i can take another look)
ah nvm. I think I found it, lesson 1 right?
While Akka does have some build-in messages you can send to your Actor (for eg: the PoisonPill message). That is something for later on.
Arjen Smits
@Danthar
May 06 2015 07:22
In the example you are looking at the "start" message that is being send to the ConsoleReaderActor. Will be the first message received by that actor. In this case. The ConsoleReaderActor does not specifically check if the message its receiving is the string "start" it just starts doing its thing.
so in this case the string "start" could have been anything really. In the example "start" is used.
Same goes for the "continue" message
The first lesson is really just to introduce you to Actors and how you pass messages between them. If you work your way through the following lessons, you will be introduced to better patterns for handling messages inside your Actor.
Does this answer your question?
Gary Ewan Park
@gep13
May 06 2015 08:06
@Danthar sorry, should have mentioned that, yes, on the first lesson :-)
ok, perfect, I will wait until digging into the remaining lessons, thanks!
Arjen Smits
@Danthar
May 06 2015 08:15
No problem. If you have any questions. Don't hesitate to ask. Plenty of guys around to answer them :)
Gary Ewan Park
@gep13
May 06 2015 08:16
:+1:
Thomas Lazar
@thomaslazar
May 06 2015 08:32
i`m currently trying to convince my boss that i can take part in the design patterns training petabridge offers… first thing he asked was "can you record it?"… i guess not. but anyone know what kind of material you get with that training?
Arjen Smits
@Danthar
May 06 2015 08:46
They way I understand it is that the training is not some video your watching, its a live webinar, and its also pretty hands-on. So I am not sure recording it would do you any good. But if you really want to you should ask @skotzko or @Aaronontheweb . Same goes for the question about what kind of material will be handled.
Thomas Lazar
@thomaslazar
May 06 2015 08:48
well hardest part about this course for me will be that it`s starting 6pm here
Arjen Smits
@Danthar
May 06 2015 08:48
whats your timezone?
.de so germany?
Arjen Smits
@Danthar
May 06 2015 08:54
either way. Reach out to @skotzko via mail about that. I know from experience those guys will try their best to accommodate you if they can.
Thomas Lazar
@thomaslazar
May 06 2015 09:13
yeah. germany. but i think ill just use the day to spend some time with the kids going to the zoo or something like that and then go to work and do the course. i dont really want to wait too long. and besides. even if they accommodate me it just means they have to get up that much earlier. and i rather have instructors that are awake ;)
Alexander Lapikov
@lapikov
May 06 2015 09:57
I am still confused with Props (both concept and naming)... You define it as "a recipe for making an actor". Can I think of it as an Actor factory? So I create an actor-type specific instance of that factory when I use Props.Create(), is it correct? And 2-nd misleading point is its name -- Props. Which term is the best synonym for it to use in following "using"?
using PropsSynonym = Akka.Actor.Props;
Arjen Smits
@Danthar
May 06 2015 09:58
Im not an expect. But let me try to answer that.
Props == Properties of the Actor
its a description of all the stuff needed to create a specific actor
thats why its "a recipe for making an actor"
its not a factory or anything. It does not actually Create an actor instance or something like that.
Arjen Smits
@Danthar
May 06 2015 10:04
That is what you do with actorSystem.ActorOf (or when inside an actor, Context.ActorOf).
Alexander Lapikov
@lapikov
May 06 2015 10:05
@Danthar, thanks for your reply. I am just trying to find an analogue in software pattern language. So Props is close to a container of actor properties needed to create its instance, right? In terms of functions its Create method is a function which explicitly takes actor implementation instance and implicitly takes configuration (including endpoints, locations, etc) in order to put all this stuff together to be able to quickly instantiate actors in context of some parent.
Arjen Smits
@Danthar
May 06 2015 10:08
That sounds about right, yes.
Bartosz Sypytkowski
@Horusiath
May 06 2015 10:18
@lapikov I would call Props more something like actor creator descriptor. Unlike factories they are not directly responsible for creating an actor but describes all configuration needed to create an actor. They also are serializable, which is important in this context
Alexander Lapikov
@lapikov
May 06 2015 10:20
@Horusiath, @Danthar, thanks guys!
varghesep
@varghesep
May 06 2015 12:06
I have come to lesson 5 in the Unit 1. Thanks for the lessons which are very good in detail. My question now is about concurrency. Let us taken an example of 5 users using the WinTail application. All five users use only a shared SINGLE file called 'CENTRALIZED-NOVEL.txt' which is hosted on the user E's machine . The user A and B use the WinTail to just watch the CENTRALIZED-NOVEL.txt. The users C and D update the shared CENTRALIZED-NOVEL.txt file. My question is, do the users A and B see the update C and D making in the same order they enter?
varghesep
@varghesep
May 06 2015 12:14
My previous question leads to another important question about transaction. I go to one ATM machine that has an application developed with AKKA.NET that does operations on a centralized bank. I have only $150 left in a joint account. I want to withdraw $100. At the same time my wife goes to a different ATM and withdraw $100 but she access the ATM few milli-seconds before I do the withdraw. In this example, I should get an error saying 'You have only $50 left in the account, so you can't withdraw $100'. Does AKKA.NET handle this use case in the order the messages are received (first from my wife's ATM and then my ATM)? Or is it possible that my wife's withdrawal message came later to the central bank later than mine and she did not get a chance to withdraw the $100. She gets the error message as a result. I appreciate your comments.
Bartosz Sypytkowski
@Horusiath
May 06 2015 12:58
@varghesep you questions are about mechanism of distributed transactions, not Akka itself. There are a lot of articles on this subject. Akka doesn't support transactions (JVM version supported them in the past but dropped them since it isn't good solution in areas, where akka is used anyway). The best option is to analyse a specific problem and design a solution suited for your case.
i.e. I think that account withdrawal examples are usually solved using event sourcing / audit logs
Thomas Lazar
@thomaslazar
May 06 2015 13:29
question about DI
do i/can i/should i add the actor system do the DI container as well. to get and use actors in components i have registered in my DI container
Bartosz Sypytkowski
@Horusiath
May 06 2015 13:50
@thomaslazar I don't see reason to. You can access current actor system from within the actor itself by using Context.System property
Thomas Lazar
@thomaslazar
May 06 2015 14:06
yeah but what if im outside the actor system. i dont need the system to access it from within an actor. i get that. i need it to have it create/receive IActorRefs when i`m outside of it.
i currently use ASP.NET + Apache Thrift as a communication stack for talking with client programs. client uses thrift to to get things done on the server. with thrift i implement handler classes. those have service methods the client can call. those handler classes are registered in my DI container. when i want to use akka within such a handler i need to get it injected into that class. so i should need to register it in the container to have it be usable in my thrift handler. or am i wrong with that?
Thomas Lazar
@thomaslazar
May 06 2015 14:12
have to go now. i hope i can catch the answer in that summery mail
Bartosz Sypytkowski
@Horusiath
May 06 2015 14:59
@thomaslazar I don't see any cons against injecting ActorSystem as parameter, as long as you maintain it in correct scope and remember to initialize it/shutdown correctly.
stevemesser
@stevemesser
May 06 2015 18:46

I am in Unit 1 lesson 5 of the BootCamp and I am having troubles with the explanation of why removing the dependency of the consoleWriterActor passed to FileValidatorActor is counter-intutive.

In the explanation it talks about how we aren't using the handle for consoleWriterActor directly. Instead we are putting that IActorRef inside a message that is getting sent somewhere else.

It seems to me that consoleWriterActor is being used directly and I don't see where it is being passed in a message???

Can anyone please enlighten me so that I can understand this concept?

Aaron Stannard
@Aaronontheweb
May 06 2015 19:29
@thomaslazar @Danthar just to give you a straight answer on the times for our virtual trainings - we're still figuring out what the ideal time of day is for delivering this stuff. We're in the US but our customers so far are all over the place (US, Australia, South America, EU) - as we collect more data on just how big the demand in each region is we'll start experimenting with more offerings specific to those timezones
@stevemesser hi Steve!
I'll try to answer your question
Andrew Skotzko
@skotzko
May 06 2015 19:30
@stevemesser sure
if you look at line 38 of FileValidatorActor
you’ll see the _consoleWriterActor gets put into a TailCoordinatorActor.StartTail message
stevemesser
@stevemesser
May 06 2015 19:31
Hi, thanks
Thomas Lazar
@thomaslazar
May 06 2015 19:31
@aaronontheweb as long as it's not like 3am for me I'm happy. ;)
Andrew Skotzko
@skotzko
May 06 2015 19:32
which later is used by TailCoordinatorActor when it takes the ReporterActor property of the StartTail message (line 45 of TailCoordinatorActor.cs)
stevemesser
@stevemesser
May 06 2015 19:32
so this line: Context.ActorSelection("akka://MyActorSystem/user/tailCoordinatorActor").Tell(new TailCoordinatorActor.StartTail(msg, _consoleWriterActor));
Andrew Skotzko
@skotzko
May 06 2015 19:32
it’s a somewhat arbitrary example, but the point is that the receiver (TailCoordinatorActor) gets a message, and inside that message is all the information it needs to do what it needs to do
yeah
Aaron Stannard
@Aaronontheweb
May 06 2015 19:33
@thomaslazar hahaha - yeah we'll try to avoid that
Andrew Skotzko
@skotzko
May 06 2015 19:34
so while there is a little coupling between the FileValidatorActor and its _consoleWriterActor handle it gets, overall the system is looser (not so much here, but the pattern holds when the system grows)
stevemesser
@stevemesser
May 06 2015 19:34
Yes, but ConsoleWriterActor is an IActorRef so how is it being using directly?
Aaron Stannard
@Aaronontheweb
May 06 2015 19:36
what the "decoupling" really does here is that it gives you the ability to decouple when the actors are created - right now they have to be created in sequence and injected through the constructors via Props @stevemesser
even though they're siblings
Andrew Skotzko
@skotzko
May 06 2015 19:37
@stevemesser it’s really just getting passed on to the TailActor, which needs it in its ctor
stevemesser
@stevemesser
May 06 2015 19:37
Ok, that makes sense, I guess I just got hung up on the difference between using something directly that is an IActorRef.
Why couldn't you select the ConsoleWriterActor with ActorSelection then pass that?
stevemesser
@stevemesser
May 06 2015 19:44
Just wondering...
Nevermind, I get it. @Aaronontheweb @skotzko Thanks!
Aaron Stannard
@Aaronontheweb
May 06 2015 19:48
anytime @stevemesser - let us know if there's anything else we can help you with!
stevemesser
@stevemesser
May 06 2015 19:49
I will thanks
Actually, one other quick question. I don't understand how sending an empty message to an Actor tell it to keep listening. My design does the Actor pause after each message?
By...
Aaron Stannard
@Aaronontheweb
May 06 2015 19:51
actors only process messages
so if there are no messages to process
they don't do anything - they're lazy :p
if the actor has a million messages in its mailbox
it'll run a million times and then wait for more messages if none have arrived during that time
Andrew Skotzko
@skotzko
May 06 2015 19:53
hey sorry, stepped away for a min there
stevemesser
@stevemesser
May 06 2015 19:54
Oh, yeah the mailbox is like a queue, correct?
empty queue nothing to do
Andrew Skotzko
@skotzko
May 06 2015 19:54
yea
stevemesser
@stevemesser
May 06 2015 19:55
@Aaronontheweb @skotzko Thanks
Andrew Skotzko
@skotzko
May 06 2015 19:55
sure thing