Broadcast a message with cluster sharding

471 views
Skip to first unread message

Jabbar Azam

unread,
May 2, 2014, 4:25:17 PM5/2/14
to akka...@googlegroups.com
Hello,

I want to create a cluster of actors using the cluster sharding module. I want to be able to send a message to all the actors in the cluster. I've read the documentation and seen the typesafe Activator example which shows messages being sent to individual actors. Does anybody know if it's possible to broadcast a message to all the actors using cluster sharding?

Basically I'm trying to implement a persistent distributed cache and I want each cache element to respond to a broadcast message which where each cache element(actor) has a resulting response. 

Jabbar Azam

unread,
May 2, 2014, 7:06:39 PM5/2/14
to akka...@googlegroups.com
I've just looked at the documentation. I can use the DistributedPubSubMediator and get all the sharded actors listening to a topic. So when I need the contents from a particular sharded actor I can send a message to a topic which will be received by all the sharded actors and the one containing the cache information will respond.

Sounds too simple. I must be missing something...

Akka Team

unread,
May 5, 2014, 4:19:52 AM5/5/14
to Akka User List
Hi Jabbar,

No, you are not missing anything, PubSub is designed for such cases. Just be careful not to broadcast too much data since it does not scale linearily.

-Endre


--
>>>>>>>>>> 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 akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

Jabbar Azam

unread,
May 6, 2014, 8:22:08 AM5/6/14
to akka...@googlegroups.com
Hello Endre,

What about one actor from each node joining the DistributedPubSubMediator and this actor could register with a node local Akka eventbus? The sharded actors could register with the local Akka event bus for messages.

So a message published to a topic, on the DistributedPubSubMediator  would be received by the local actor joined to DistributedPubSubMediator which would then publish the message to the local Akka eventbus. I think this would work. I'm  assuming I'll have >10,000 actors per node, but don't know until the rest of the system is in place.  Each actor will be storing GPS coordinates for a rectangular region and will be used as an index into Cassandra tables.

Chanan Braunstein

unread,
May 6, 2014, 9:14:19 AM5/6/14
to akka...@googlegroups.com
Hi Jabbar,

We were thinking of that same design. If you implement before we do, please share your experiences with that design and we will do the same.

Chanan

Jabbar Azam

unread,
May 6, 2014, 9:30:22 AM5/6/14
to akka...@googlegroups.com
Hello Chanan,

This is an evening project for me so you might get it done before me. Although I got the cluster sharding, with cassandra, working last night.

Patrik Nordwall

unread,
May 6, 2014, 11:40:01 AM5/6/14
to akka...@googlegroups.com
That is how topics are implemented (but not with the eventbus). A message published to a topic is only transferred over the wire once to each node that has subscribers and then delivered to all local subscribers.

/Patrik
--

Jabbar Azam

unread,
May 7, 2014, 4:01:08 AM5/7/14
to akka...@googlegroups.com
Thanks Patrik,

The pub/sub code works. It was really simple to work with.

Patrik Nordwall

unread,
May 7, 2014, 4:25:45 AM5/7/14
to akka...@googlegroups.com
On Wed, May 7, 2014 at 10:01 AM, Jabbar Azam <aja...@gmail.com> wrote:
Thanks Patrik,

The pub/sub code works. It was really simple to work with.

You're welcome. Glad to hear that.

/Patrik 



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Reply all
Reply to author
Forward
0 new messages