bi-directional pubsub

175 views
Skip to first unread message

ash.ta

unread,
Dec 28, 2015, 5:59:49 AM12/28/15
to Akka User List
hi,

i'm looking for a solution for the following task:

i have 2 types of actors. their instances can be deployed in a local non-distributed environment or in a cluster, where they can be also available in the same node or on different nodes.

these actors have to exchange messages in a stateless manner (like in microservices' event bus messaging style) without knowing where exactly their addressee is deployed.  

i see the following example in the distributed pubsub docs:

ActorRef mediator = DistributedPubSub.get( getContext().system() ).mediator();
...
mediator.tell( new DistributedPubSubMediator.Send( "/user/destination", out, localAffinity ), self() );

my problem is that mediator currently supports tell() only, but i need a possibility to receive callback with a reply to original call, something like Patterns.ask().
does akka provide any solution for this? 
since i'm a total newbie, i'll also appreciate your advice in case i have to look for a solution based on other features. 

thanks. 

Patrik Nordwall

unread,
Dec 28, 2015, 8:53:17 AM12/28/15
to Akka User List
mediator is an ActorRef so you can use ask. Note that ask is in akka.pattern.Patterns.ask

/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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Asher Tarnopolski

unread,
Dec 28, 2015, 10:17:17 AM12/28/15
to akka...@googlegroups.com

patrik,

thanks for your prompt response.
another question: does mediator incorporate some kind of cluster management under the hood? for example, what happens in case all nodes with the addressee actor are removed? will i get a time out waiting for a callback or some kind of exception will be immediately thrown?

thanks again!

p.s. i use java api, if it's important.


You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/DJFaDLNVWVA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.

Patrik Nordwall

unread,
Dec 28, 2015, 11:17:29 AM12/28/15
to akka...@googlegroups.com
Then you will get ask timeout

ash.ta

unread,
Dec 28, 2015, 1:06:56 PM12/28/15
to Akka User List
patrik, thanks again.

the last question for now, i really appreciate your help.
the docs say: 

If subscribing with a group name, each message published to a topic with the (sendOneMessageToEachGroup) flag is delivered via the suppliedRoutingLogic (default random) to one actor within each subscribing group
 
so, i'm doing something like

Future<Object> future = Patterns.ask( mediator, new DistributedPubSubMediator.Publish( "destination", messageObject, true  ), new Timeout( Duration.create( 5, "seconds" ) ) );

do you know  how can i set the RoutingLogic here programatically?
 

Patrik Nordwall

unread,
Dec 28, 2015, 4:33:44 PM12/28/15
to akka...@googlegroups.com
You can change the routing logic in configuration.
You can't change it for each message.
It's possible to set it programatically. Then you do it via DistributedPubSubSettings and have to create the DistributedPubSubMediator actor yourself instead of using the DistributedPubSub extension. I recommend configuration.

--
Reply all
Reply to author
Forward
0 new messages