You can perhaps use Distributed Pub/Sub <http://doc.akka.io/docs/akka/2.4/java/distributed-pub-sub.html> for this. The difficult part is to reliably deliver the messages to all subscribers. Messages may be lost or subscribers may not be running when you consume the message from Rabbit. That is not handled by Distributed Pub/Sub and if it's important it's something you would have to think about if you roll your own solution also.
Regards, Patrik On Wed, Jan 11, 2017 at 11:23 AM, Ivan Nakov <[email protected]> wrote: > Hi guys, > > I have a service that consumes messages through RabbitMq channel and > should forward them to PersistentActors behind ClusterShard. > The tricky part is that each persistent actor must subscribe himself for a > specific messages and receive all messages from these types. For example: > message1 - should be delivered -> persistenceId1, persistenceId2, > persistenceId3 > message2 - should be delivered -> persistenceId1, persistenceId4 > > I'm thinking for the following solution: > > 1. Implement a MessageCоordinator as cluster singleton. The > Coordinator is going to contain all subscription and persist them. > 2. Every persistent actor is going to register himself after > initialization in the Coordinator. He's going subscribe messages with his > persistentId(insted of ActorRef). > 3. Each node is going to start its own "MessageRouter". The router is > going to fetch recipients list from the Coordinator and subscribe for > update of the list with it's ActorRef. If there is change in list the > coordinator is going to notify all routers. > > Is my approach reasonable? Is there a better solution to this problem? > > > Cheers, > Ivan Nakov > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/ > current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Patrik Nordwall Akka Tech Lead Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM Twitter: @patriknw -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
