How to make inquiries in a collection of actors

I have an acting system that currently accepts commands / messages. The state of these actors is preserved in Akka. Now we want to create a query system for this acting system. Basically, our problem is that we want to have a way to get a collection / list of all the states of these specific participants. Although I do not fully subscribe to the CQRS template, I think this may be a neat way to do this.

My initial thoughts were to have an actor for the request, which contains as part of its state an aggregation of the states of other participants who perform the “data recording”. And to do this, this actor will subscribe to the participants who are interested in him, and these actors will simply send the actor’s request to their states when they undergo some kind of state change. Is this the way to it? Is there a better way to do this?

+4
source share
2 answers

My recommendation for implementing this type of template is to use a combination of pub-sub and push-and-pull messages for your members here.

"" , . , , , .

aggegrate , ( ), , , .

, , . , , , , . , : https://petabridge.com/blog/akkadotnet-at-least-once-message-delivery/

+1

Akka.Persistence(.. , SQL) - Akka.Persistence.Query. , , Akka.Streams.

SQL-, Akka.Persistence.Query.Sql Akka.Streams. ( ) , . :

using (var system = ActorSystem.Create("system"))
using (var materializer = system.Materializer())
{
    var queries = Sys.ReadJournalFor<SqlReadJournal>(SqlReadJournal.Identifier)

    queries.EventsByPersistenceId("<persistence-id>", 0, long.MaxValue)
        .Select(envelope => envelope.Event)
        .RunForEach(e => Console.WriteLine(e), materializer);
}
+1

Source: https://habr.com/ru/post/1667913/


All Articles