Broadcast messages are not working in a cluster?

120 views
Skip to first unread message

Eugene Dzhurinsky

unread,
Dec 24, 2014, 5:12:39 PM12/24/14
to akka...@googlegroups.com
I'm trying to create a simple proof of concept for working with a group of actors in a cluster.

I've created the following example 


the problem is - sending a Broadcast message to a consistent-hashing-group router, obtained from the cluster configuration - seems to send a message only to a single routee - not all of them.

The sample output from the code above:

Started akka://Test/user/routeeA/$h
Started akka://Test/user/routeeA/$i
Started akka://Test/user/routeeA/$f
Started akka://Test/user/routeeA/$j
Started akka://Test/user/routeeA/$a
Started akka://Test/user/routeeA/$g
Started akka://Test/user/routeeA/$b
Started akka://Test/user/routeeA/$c
Started akka://Test/user/routeeA/$e
Started akka://Test/user/routeeA/$d
Started akka://Test/user/splitter/$b
Started akka://Test/user/splitter/$a
Received data to process
Broadcasting work for akka://Test/user/routerA
Received broadcast from akka.tcp://Te...@127.0.0.1:2552/user/splitter/$a
Worker Actor[akka.tcp://Te...@127.0.0.1:2551/user/routeeA/$a#410953742] wants some data
Process to respond akka.tcp://Te...@127.0.0.1:2552/user/splitter/$a
Worker Actor[akka.tcp://Te...@127.0.0.1:2551/user/routeeA/$a#410953742] completes its job


As it is seen - the only one actor receives the broadcast message - not 10, which is weird.

Can you please advice how to fix that (without using DistributedPubSubMediator)?

Thank you!

Eugene Dzhurinsky

unread,
Dec 24, 2014, 8:49:53 PM12/24/14
to akka...@googlegroups.com
I have changed the line

router ! Broadcast(WhosOnDuty)

into 


router ! ConsistentHashableEnvelope(Broadcast(WhosOnDuty), WhosOnDuty)

And that solved the issue. So it seems the cluster-aware router "unwraps" the Broadcast message and then passes it to the, thus using the "normal" delivery mode for the given route.

Interestingly, the code

router ! Broadcast(Broadcast(WhosOnDuty))

works as expected too - so the message is being sent to all routees.

I don't know if it's an expected behavior, but seems to be quite surprising for me.

Dmitry Semenov

unread,
Dec 25, 2014, 1:59:18 PM12/25/14
to akka...@googlegroups.com
Not sure if it relative to the problem you want to solve, but you can do following stuff to get all routees

def guardianReceive: Actor.Receive = {
case DiscoverChildren ⇒
router ! GetRoutees
case Routees(routees) =>
routees.foreach {
case ActorRefRoutee(ref) => addWorker(ref)
ref ! GuardianRegistration
}
}

Patrik Nordwall

unread,
Jan 2, 2015, 9:09:06 AM1/2/15
to akka...@googlegroups.com
Hi Eugene,

That should be fixed. I have created an issue.
https://github.com/akka/akka/issues/16611

Thanks for reporting.

/Patrik

--
>>>>>>>>>> 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.



--

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

Assaf Abulafia

unread,
Mar 25, 2017, 6:17:29 AM3/25/17
to Akka User List
Hi,

any idea if that issue ended up in akka 2.4?
I'm stumbling upon something similar, not sure if this is the same bug or not,
when sending a Broadcast to all actors behind a consistent hashing router, I get the following error (where MyMessage is the broadcast's payload)

a.routing.ConsistentHashingRoutingLogic  : Message [MyMessage] must be handled by hashMapping, or implement [akka.routing.ConsistentHashingRouter$ConsistentHashable] or be wrapped in [akka.routing.ConsistentHashingRouter$ConsistentHashableEnvelope]

thanks,
Assaf
Reply all
Reply to author
Forward
0 new messages