These are chat archives for akkadotnet/akka.net

18th
Oct 2016
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 02:34
question, since the async and await keyword is pretty much banned in akka.net, do i need to use PipeTo in ReceiveAsync?
and i'm not allowed to do something like... ReceiveAsync<MyClass>(async message => {}); ?
John Nicholas
@MrTortoise
Oct 18 2016 08:04
you can still use tasks. They are useful in those cases.
when using tasks the ReceiveAsync seems to be the way if you do not want your actor to be reenterant (which is probably the case otherwise you can have state changes prior to the PipeTo or ContinueWith continuation
Juan José De Arana
@juanjoarana
Oct 18 2016 08:08
@Silv3rcircl3 oh, great, was not able to find in the documentation these details. I'll try to review AKKA.net documentation to understand the details on serialization. Thanks so much.
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:13
@MrTortoise you mean by doing something in the line of Task.Run(MyAsyncFunc(param, Sender));?
Ash R
@AshRolls
Oct 18 2016 08:13
@MrTortoise The messages I was referring to had no content, they were just useful for signalling, so instead of creating a new instance of the class each time I stored one, and used it repeatedly
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:32
i guess i'm just not getting the purpose of ReceiveAsync actors...
verilocation
@verilocation
Oct 18 2016 08:33
I think that given that multiple Actors will run within a thread, using just Receive would be a blocking event. ReceiveAsync will allow multiple Actors to run concurrently with less blocking
When I switched to ReceiveAsync I saw a big performence boost
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:35
hmmm... so just switch the base type to ReceiveAsync but keep everything inside as non-async?
John Nicholas
@MrTortoise
Oct 18 2016 08:35
@Arkatufus Well the case i was thinking of would be on an edge of the system where you hit a resource that is not in akka. Often that call might be async with a task continuation because you don't want to block the actor. However if you have a situation where you need something in the actors state and dont want to risk anything else coming in and trampling on it, then you would use it.
verilocation
@verilocation
Oct 18 2016 08:36
@Arkatufus You would use it when your Receive method needs to call an external resource (such as use an Ask or call a database). Otherwise theres no point.
John Nicholas
@MrTortoise
Oct 18 2016 08:36
hang on maybe i misunderstand ... In recieve when you start a task and put a continuation on it. my understanding is that the recieve handler ends before the continuation executes.
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:37
@MrTortoise yes, i was trying to figure out a way to do CRUD to a database asynchronously from akka
verilocation
@verilocation
Oct 18 2016 08:39
in which case you'd use async on that i.e.
this.ReceiveAsync<DbRequest>(request =>
{
    var result = await this.dbContext.Where(user => user.Id == request.UserId);
});
Syed Hassaan Ahmed
@bannerflow-hassaan
Oct 18 2016 08:39
Question: We have an Akka.Cluster deployment where one of our Nodes is hosted as a Topshelf service. The Node uses Akka.Persistence for Actor state recovery in case of Service restart/upgrades. Deployment script successfully performs these steps: stop->uninstall->reinstall new version->start the service. We're using Redis for persistence and can see that the "journals" are present with correct state. However, after the service is started, we see this error in NLog causing state loss. "Persistence failure when replaying events for persistenceId [workerSupervisorActor]. Last known sequence number [0]" Has anyone seen similar issue before?
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:40
@verilocation you're not supposed to use await inside Receive though, because when it is loaded later in a different thread, the context might have changed
at least thats what i've read so far
verilocation
@verilocation
Oct 18 2016 08:42
Oh... I thought await in C# was essentially syntatic sugar for wrapping your code in a Task and then ContinueWith... Wouldnt that preserve the correct context? Maybe I'm wrong. (Perhaps a little knowledge is dangerous!)
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:43
no idea... thats why i asked in the first place XD
John Nicholas
@MrTortoise
Oct 18 2016 08:43
await does execute on the callign context
.continueWith is configurable
Go down to "Actors + Async FAQ"
Its been updated
John Nicholas
@MrTortoise
Oct 18 2016 08:45
I think your right about syntactic sugar btw, personally i hate it ;p but it has uses
verilocation
@verilocation
Oct 18 2016 08:45
Ohhhh no await is awesome... At for those of us with a OOP rather than functional background
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:45
@verilocation alright, lemme read that real fast
John Nicholas
@MrTortoise
Oct 18 2016 08:46
excellent thanks that answers all my questions also
so ReceiveAsync effectivley runs in single thread mode and blocks until the await completes
verilocation
@verilocation
Oct 18 2016 08:47
It blocks the Actor not the thread
John Nicholas
@MrTortoise
Oct 18 2016 08:47
however you only need to do that if other calls on the aactor would effect state that is required by the awaiting operation
verilocation
@verilocation
Oct 18 2016 08:47
Actors run concurrently rather than in parallel, so multiple Actors could run on one thread
Gregorius Soedharmo
@Arkatufus
Oct 18 2016 08:47
@verilocation oooh... thats good news, thanks dude, really good info there
John Nicholas
@MrTortoise
Oct 18 2016 08:47
i did say its as if one thread, same thing - ok dont want to get into splitting hairs. I was considering one actor in isolation as if one thread (but yes your right ;p)
verilocation
@verilocation
Oct 18 2016 08:49
Sorry didnt meant to be pedantic, sometimes its best to be, to ensure everyones on the same page :)
John Nicholas
@MrTortoise
Oct 18 2016 08:50
nono i agree, i make horrible abstractions when thinking and dont sufficiently explain myself
bad habit from physics ;p
verilocation
@verilocation
Oct 18 2016 08:50
Me too :D In fact sometimes I come out with pure nonsense and wonder why people don't understand me lol. The curse of being a developer huh?
John Nicholas
@MrTortoise
Oct 18 2016 09:03
idd
Syed Hassaan Ahmed
@bannerflow-hassaan
Oct 18 2016 10:36
Hi guys .. any Akka.Persistence gurus here? :smile:
Question: We have an Akka.Cluster deployment where one of our Nodes is hosted as a Topshelf service. The Node uses Akka.Persistence for Actor state recovery in case of Service restart/upgrades. Deployment script successfully performs these steps: stop->uninstall->reinstall new version->start the service. We're using Redis for persistence and can see that the "journals" are present with correct state. However, after the service is started, we see this error in NLog causing state loss. "Persistence failure when replaying events for persistenceId [workerSupervisorActor]. Last known sequence number [0]" Has anyone seen similar issue before?
Francis Paulin
@paulinfrancis
Oct 18 2016 14:17
Does anybody know if you should be able to serialize an ExpandoObject, using the Wire serializer?
Daniel D'Agostino
@dandago2_twitter
Oct 18 2016 14:47
Question: in order to test handlers with dependencies on other actors, you basically need to pass the IActorRef using constructor injection, so that from tests you can pass in a TestProbe instead. But by doing this, you screw up the hierarchy because an actor needs to create its child actors. How can you use constructor injection for testability AND have an actor create its children?
verilocation
@verilocation
Oct 18 2016 15:56
I'm sure this has been asked a lot, but is there a way to get stats about an ActorSystem? I know I can subscribe to Cluster Events such as IMemberEvent and UnreachableMember to gauge the reach-ability of various Actors and nodes within the system. But ideally I'd like to also find message throughput and mailbox size for each actor. Any tips or suggestions on how to accomplish that? Similar to : http://image.slidesharecdn.com/effectiveakkascalaio-131024193030-phpapp02/95/effective-akka-scalaio-43-1024.jpg?cb=1382643119
Peter Bergman
@peter-bannerflow
Oct 18 2016 18:05
@verilocation One thing you could look into if you haven't done so already is Akka.Monitoring https://github.com/petabridge/akka-monitoring
Marc Piechura
@marcpiechura
Oct 18 2016 19:38
@dandago2_twitter what's the connection between constructor injection and child creation ?
Normally the actor under test would send the injected test actor a message and the test actor would assert that it received the message and maybe send a response
Don't see why this would screw up the hierarchy
John Nicholas
@MrTortoise
Oct 18 2016 19:41
i think he means supervision heirachy
Marc Piechura
@marcpiechura
Oct 18 2016 19:44
Is the same too me, the parent automatically is the supervisor of it's children
John Nicholas
@MrTortoise
Oct 18 2016 19:45
but if you inject something instead of create it as a child then the supervisor will be different in both cases.
Marc Piechura
@marcpiechura
Oct 18 2016 19:47
So the question is how you test that you send your child the correct messages
John Nicholas
@MrTortoise
Oct 18 2016 19:48
yes, i think that's his question.
Marc Piechura
@marcpiechura
Oct 18 2016 19:51
I see, so afaik it's not possible to return the TestActor instead of the actual child if you call Context.ActorOf. What you could do is inject the Props in the parent actor and use them for child creation, normally they would contain the actual child, but in your test you can inject a different "mock" actor props
Marc Piechura
@marcpiechura
Oct 18 2016 19:58
The question is do you really need this? Normally something should happen after you created the child, if you only want to check if it was created, use actor selection and if your child does some processing it normally would send a message back to the original sender which would be again the test actor
John Nicholas
@MrTortoise
Oct 18 2016 19:59
haha ive been sat here also. I would question if the tests are actually testing a unit or whether they are about to go too fine grained
Marc Piechura
@marcpiechura
Oct 18 2016 20:03
Yup
That's the right question ;)
Andrew Young
@ayoung
Oct 18 2016 20:29
Ok. I realize this isn't directly related to Akka. But has anyone here had to deal with indirect dependencies not being copied to the bin folder? For example, the dependency chain is C -> B -> A. The bin folder in A does not have C.dll.
This is happening for Akka.dll and the Cluster.dll because if you define everything in HOCON, you aren't referencing Cluster in your code anywhere. So msbuild just optimizes it out.
Daniel D'Agostino
@dandago2_twitter
Oct 18 2016 21:30
So, my question was: if you want to create actor B as a child of A, you pretty much can't use constructor injection... so how would you mock B?
For those picky on definitions, we're not talking unit tests here - those are pretty much impossible with Akka .NET
what would you want to test after you created the child? basically, that the child receives a message.
John Nicholas
@MrTortoise
Oct 18 2016 22:49
id test the output is expected given the input
qwoz
@qwoz
Oct 18 2016 23:38
What's the best way to model and query a large number of items? Let's say I want to build an API for a book library and have API calls returning "Top 1000" lists for: most popular books, most borrowed books, most overdue books, etc. If each book is its own actor and there's a BookManager which handles messages sent to /user/books, how should that get stored and queried? Would the BookManager receive a GetMostPopular message from an API request, query a database for the 1000 books by popularity, then instantiate a thousand actors representing (for example) book-0001 through book-1000, query each book actor for its information, wait for all to return the requested data, aggregate it all together, and provide a single response to the API?
qwoz
@qwoz
Oct 18 2016 23:55
Or do you ignore actors when querying multiple, directly using the database instead, and only reference an individual book actor when you want to perform an operation on a particular book (borrow, place hold, return, etc.)?