These are chat archives for akkadotnet/akka.net

7th
Dec 2016
Rich Cox
@conejo
Dec 07 2016 01:17
.NET has the SslStream class for doing TLS (https://msdn.microsoft.com/en-us/library/system.net.security.sslstream(v=vs.110).aspx), but it needs the TcpClient so it can wrap it's networkStream. I've been looking through the Akka.IO classes, but don't see where TcpClient is used.
Garrard Kitchen
@garrardkitchen
Dec 07 2016 07:23
If I executed an Ask against a BroadcastGroup that consisted of 2 endpoints, how many responses should I expected? One or two?
Arjen Smits
@Danthar
Dec 07 2016 07:38
@garrardkitchen ask can only return one response. But im not sure how it would react, i would expect it to return as soon as the first response is received.
But if you want behavior like that, it sounds like you would be better of with an scatter gather router: http://getakka.net/docs/working-with-actors/Routers
Alex Michel
@amichel
Dec 07 2016 07:58
Anyone worked with Akka.Persistence.Redis ?
Garrard Kitchen
@garrardkitchen
Dec 07 2016 08:36
Thank you @Danthar
Alex Michel
@amichel
Dec 07 2016 10:43
WIth Cluster Sharding if I don't care about state of actor, but only about serializing all messages to my entities, I don't have to make it a persistent actor. It is enough that Shard will be serialized and persisted along with its messages buffer and relevant actor refs, right?
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 11:07
@amichel yes
keep in mind that message buffer is not persisted. Messages will be redirected when graceful shutdown will occur, but in case of hard crash messages are lost
@conejo akka io doesn't use tcp client, it operates on raw sockets. This is an implementation detail thou - in near future it will work over AsyncSocketEventArgs
Arsene T. Gandote
@Tochemey
Dec 07 2016 11:47
Hello Geeks
Alex Michel
@amichel
Dec 07 2016 11:53
@Horusiath Is there a way to persist message buffer, or better just use RabbitMQ and subscribe to it from Akka if I want be able to consume requests published when node or whole cluster was down?
Arjen Smits
@Danthar
Dec 07 2016 12:05
@amichel you could certainly use RabbitMQ as an front facing message buffer for your cluster. However depending on your use case, you might very well be moving the problem elsewhere, instead of fixing it.
Alex Michel
@amichel
Dec 07 2016 12:09
@Danthar I understand. Just trying to figure out how to solve it. With pure RabbitMQ implementation, durable queues and router/exchange of my choice I don't have this problem when consuming it from several instances, but then I need to handle the logic of moving shards and rebalancing when one of instances fails. With Akka I don't have durability. Should I implement durable message buffer with RabbitMQ?
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 13:08
@amichel common pattern is to set a persistent queue in front of the cluster. Most of the time what you want to persist are user requests or some important domain requests, but usually there's not sense in persisting every message passed between two actors
Alex Michel
@amichel
Dec 07 2016 14:14
@Horusiath it means I can't use cluster proxy in frontend, but run cluster in backend with actors consuming persistent queue?
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 15:13
@amichel when using persistent queue at frontend, then yes. But it really depends on what you need:
  • you could potentially use AtLeastOnceDelivery with Akka.Persistence module (I've created a sample of such persistent gateway some time ago), but this comes with performance drop and potentially the same message being emitted more than once.
  • For immediate user requests you can also simply use request/response pattern with message timeouts - so if you have cluster proxy in frontend, simply send request to target actor and expect response within specified timeout. If response won't arrive (cluster node has crashed or message has been lost for any other reason), consider request as unfulfilled.
Alex Michel
@amichel
Dec 07 2016 15:16
@Horusiath Thanks a lot. I will stick with proxy and the request/response solution
Alex Achinfiev
@aachinfiev
Dec 07 2016 16:33

I am trying to use Become in PersistentReceiveActor to switch from Uninitialized to Initialized state but I get an error:
[Akka.Actor.OneForOneStrategy]: You may only call Recover-methods when constructing the actor and inside Become().
In my actor I have:

Become(Uninitialized);
private void Uninitialized()
{
        Recover<SecurityCreated>(e => Create(e));
        Command<CreateSecurity>(c => ...);
}

This used to work in the PersistentActor before. How should Become be declared now? Is there an updated example? Or if I use anonymous action inside Become call, how do I switch to it from other parts of the code? Thanks.

Alex Achinfiev
@aachinfiev
Dec 07 2016 16:46
@aachinfiev Update:
So it looks like I just need to move all Recover methods back to ctor and leave commands in corresponding Initialized/Uninitialized actions that are switched using Become.
Aaron Stannard
@Aaronontheweb
Dec 07 2016 16:47
oh I see
yeah it's not being able to mix and match Recover and Command inside the same behavior
Recover only gets used during the actor's initial recovery phase
those should be called from the CTOR, like you said
the commands behave like normal receives
you can behavior-switch those
Alex Achinfiev
@aachinfiev
Dec 07 2016 16:48
Yes. I understand it better now :)
@Aaronontheweb Btw. Are there any plans to bring Akka.Persistence.Cassandra to work with latest 1.0.2 Akka.Persistence? I saw you update on one of the PRs but that was a while ago.
Aaron Stannard
@Aaronontheweb
Dec 07 2016 16:53
yep, we're working on it
have an evil plan underway to get all of the Akka.Persistence implementations running with full integration testing again
which is what we've been waiting on
Alex Achinfiev
@aachinfiev
Dec 07 2016 16:54
Is part of that update to change schema to support reverse lookup views by tags?
Aaron Stannard
@Aaronontheweb
Dec 07 2016 16:55
yeah should be as part of Akka.Persistence.Query
which that PR supports
Alex Achinfiev
@aachinfiev
Dec 07 2016 16:56
Cool
Aaron Stannard
@Aaronontheweb
Dec 07 2016 16:56
the damn thing that's taken so long is getting our toolchain to play nice with Docker
spin up a Docker container for whatever database target we're testing against
allows for a bunch of fun stuff like being able to test against multiple versions of the same database simultaneously
Alex Achinfiev
@aachinfiev
Dec 07 2016 16:58
Yeah, I have been building a docker stack for our various data stores (cassandra, elasticsearch, orientdb) to spin that up locally for testing. Works great with docker-compose, and then you can destroy the whole thing and start fresh quickly.
Aaron Stannard
@Aaronontheweb
Dec 07 2016 16:58
I tried getting DataStax Enterprise to run inside Docker two weeks ago
failed miserably at that
too many issues with file system permissions inside the container
whereas it "just works" on a Ubuntu VM
I felt very un-hip :(
Alex Achinfiev
@aachinfiev
Dec 07 2016 17:01
I currently didn't bother mounting the volumes because for local testing I don't want them to live for long. As long as I don't destroy container I can stop/start with the data. But if I do compose down then it starts fresh. Very handy.
Right now trying to figure out how to tweak our coordinator that manages persistent actors to kill them efficiently and without loosing messages. Current implementation keeps taking longer and longer during sustained load when I push thousands of messages through it. If I let coordinator kill the child immediately it keeps constant level of response time but looses in-flight messages.
Alex Achinfiev
@aachinfiev
Dec 07 2016 17:25
@Aaronontheweb Have you guys tried to run Akka stack on Docker yet?
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 17:58
@aachinfiev Afaik @annymsMthd has a production system working on akka/mono/docker - he even published some docker scripts some time ago
Alex Achinfiev
@aachinfiev
Dec 07 2016 19:52
@Horusiath Cool. Good to now. Thanks.
Eric Glanz
@ericgla
Dec 07 2016 20:20
I'm new to Akka.Net, and am testing out scenarios where a child actor stops using the OneForOneStrategy I defined. Everything is working as expected, but I never seem to get a Terminated message on the parent when the child actor stops.
Looking at the Actor lifecycle diagram in the docs, I should be seeing a Terminated message at the parent. What am I missing here?
Eric Glanz
@ericgla
Dec 07 2016 20:28
and just after posting I answered my own question.... child actors are not watched by default (which was my assumption), and need to be explicitly watched with Context.Watch(childActor)
Yin Zhang
@melcloud
Dec 07 2016 20:30
Hi guys, do we have documents on how split brain problem is handled in akka.net? There is a good amounts of articles for akka, not sure if akka.net uses the same mechanism
Arjen Smits
@Danthar
Dec 07 2016 20:40
yes it does
generally the jvm akka docs apply to akka.net as well
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 21:13
@melcloud I don't remember if custom downing provider are already present in the akka.net version available on nuget, or it's still laying down in dev branch
anyway by default no downing strategy is provided. You can change that to auto-down (which means that every node will automatically mark as downed other nodes it couldn't reach within specified timeout) - but this may lead to split brain situation.
On the akka jvm you have at least 4 more downing providers, but they are part of reactive subscription and are part of Lightbend's proprietary stack
Yin Zhang
@melcloud
Dec 07 2016 21:44
@Horusiath ah, got it. Yes, those 4 downing providers are what I am looking for. This means in akka.net, we need to keep monitoring status to manually downing actor?
Matthew Little
@zone117x
Dec 07 2016 22:01
Hey guys curious of akka.net is good for my use case. I have an asp.net core server brokering messages between clients on net451 using websockets and msgpack serialization
the net451 client apps are 1) data collector, and 2) remote controller for the data collector and data viewer
Yin Zhang
@melcloud
Dec 07 2016 22:02
@zone117x so what would you like to use akka.net for ?
Matthew Little
@zone117x
Dec 07 2016 22:04
I'm having to write a lot of code to manage the websocket connection and especially message routing
Yin Zhang
@melcloud
Dec 07 2016 22:06
I see. Does the .ne tcore server doing any thing special?
Matthew Little
@zone117x
Dec 07 2016 22:07
its using asp.net core mvc for the web interface and some REST apis, and routing for the websocket connections
Yin Zhang
@melcloud
Dec 07 2016 22:09
So you want to replace routing part of the websocket connections?
The akka.net is not available on net core yet. (correct me if I am wrong)
But for you situation, can you just use a load balacer / proxy to route traffic instead of relying on code?
Matthew Little
@zone117x
Dec 07 2016 22:10
I'd like to use it for message routing over the websocket connections
Alex Achinfiev
@aachinfiev
Dec 07 2016 22:31

I have a PersistentReceiveActor that sends itself a PoisonPill after 5 seconds of inactivity. I see a scenario where I see WriteMessagesSuccessful & WriteMessageSuccess are going to deadletter from akka.persistence.journal.inmem that were directed to the given actor. Does missing those messages mean that Persist callback won't wire or these are used for other confirmation?

        Command<CreateSecurity>(c =>
        {
            Persist(new SecurityCreated() { Id = c.Id, Name = c.Name }, e =>
            {
                Context.System.EventStream.Publish(e);
                Create(e);
                BecomeInitialized();
            });
        });
       Command<ReceiveTimeout>(t => Self.Tell(PoisonPill.Instance));
....
    protected override void PreStart()
    {
        base.PreStart();
        Context.SetReceiveTimeout(TimeSpan.FromSeconds(5));
    }

Or those are just confirmation and actor correctly persisted the data? Thanks.

Yin Zhang
@melcloud
Dec 07 2016 22:34
@zone117x I assume u route message based on some message property, lets say postcode. You can definitely have actor which listen for incoming requests, look up postcode, spin up a child and begin a web socket connection there. But akka.net currently has no support for .net core, which means somehow you need to proxy it to a net451 app.
Yin Zhang
@melcloud
Dec 07 2016 22:43
@aachinfiev yes, it is used by AsyncWriteJournal.cs to send reply to requestor upon sucessfully write
@aachinfiev is there any reason you want to self destruct a persist actor?
Justin Oehlmann
@GREETASolutions_twitter
Dec 07 2016 22:48
quick poll ..akka.noob Reactive Messaging patterns or Functional and Reactive Domain Modeling
?
to clarify as a new player to akka.net which book would you choose first ?
Kevin Avignon
@Kavignon
Dec 07 2016 22:53
I have a system of actors in mind. Once the first actor starts and arrive has a point where another must be started or get the actor that is already alive, how would one do this ? This would be like a master-slave relationship
One big actor with three children that be either created or are already reactive.
I'm doing this with F# *
@Horusiath
Alex Achinfiev
@aachinfiev
Dec 07 2016 22:54
@melcloud I have a coordinator that manages a lot of child persistent entities. If I don't destroy them either by coordinator or self destruct when I will have thousands of entities in memory. I could be importing 100k - 500k securities for example. I want to keep # of children bound.
@melcloud Unless there is another design pattern to manage this better.
Yin Zhang
@melcloud
Dec 07 2016 22:58
@aachinfiev I see. Are you treating them as routee? You want to handle each request with one actor, or just has a pool/group persistence actor to handle all the requests?
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:00
@melcloud I have AggregateCoordinator that spawns AggregateRoot per entity (DDD) and I am importing a lot of events. There is a separate coordinate per each type of entity. But there could be lots of entities for a given type. And events can come fast during import. E.g. 100k in a row for a security coordinator.
Yin Zhang
@melcloud
Dec 07 2016 23:03
I see. I don’t see the problem of keeping them alive if they are boudned (e.g. 1000). Because relatively they are doing anything. However, I don’t think you should spin up 100k - 500k persist actor, as you may open that many connections at the same time. It is not great idea. Perhaps think about back pressure and akka stream?
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:06
Akka Streams is something I want to move at some point, but I am not able to get there just yet. Isn't persistence actor can only represent a single entity by design? I didn't think you can dynamically swap it's persistence Id to handle more than one unique entity.
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:07
@aachinfiev what persistent backend are you using?
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:08
Akka.Persistence.Cassandra (1.0.6) atm with Akka.Persistence 1.0.6 because it's not compatible with 1.2.0 yet
If I could spawn a fixed number (say M = 1000) of persistent actors to handle N (say 100k) entities and each new id dynamically replays state for new message that would work. But I don't know if it works that way.
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:11
@aachinfiev having 100k-500k actors may not be that bad (you probably relax amount of memory used by the process). If you're going to use them anyway within close time range, it's better to have them in memory than trying to kill some of them and respawn on demand -> latter is much more expensive.
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:11
Using sharding won't help me here, since I don't want to keep all 100k of them in memory regardless.
100k-500k is an arbitrary number. I can have other record types during import that may go into millions.
Most of the requests are for a new entity .. with sometimes updates to existing one during same import
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:12
I would measure how much memory does it take. Probably few GB
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:15
And after each import send a purge request to reclaim memory? I have a number of services running and box has only 8 - 16gb in total.
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:15
@Kavignon you must clearly define actors relationship. Because actors that can be either created or already active doesn't fit master-slave scenario (as slave may be already there, where master is being created or I get your case wrong)
@aachinfiev actor-based systems are stateful by default, and this also means they'll consume a lot of memory. Maybe actor-per-entity is not a good option for you, and you need something lighter indeed
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:20
(if you really need, you may fabricate a message that persistent actor sends to its journal when it's going to persist an event: see example)
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:22
So you directly communicate with Journal rather than making a persitentactor do one message at a time?
I.e. pool a set of messages and then batch them to journal to persist
Bartosz Sypytkowski
@Horusiath
Dec 07 2016 23:23
I'm using this when I want to have compatibility with akka.persistence protocol without actually creating thousands of actors
for persisting multiple events at once you may just use PersistAll method
Alex Achinfiev
@aachinfiev
Dec 07 2016 23:25
Your first point is my use case for the import case. Looks very interesting. I need to check that out. Thanks :)
Michael Chandler
@optiks
Dec 07 2016 23:36
Hello. Is it possible to intercept ICanTell.Tell()? I'd like to add some logging. Or would this be better done by monitoring the mailbox or
  • or some other means.
Basically, I want to be able to visualise the messages flying around. I'd like to generate a sequence diagram or similar. AroundReceive works for the receiving side, but not the sending side.