routing,akka,dispatcher,event-bus , Akka messaging mechanisms by example


Akka messaging mechanisms by example

Question:

Tag: routing,akka,dispatcher,event-bus

I have a fair amount of Apache Camel (routing/mediation/orchestation engine; lightweight ESB) experience and am racking my brain trying to understand the difference between Akka:

According to the docs:

Dispatchers are:

...is what makes Akka Actors “tick”, it is the engine of the machine so to speak.

But that doesn't really explain what a dispatcher is or what it's relationship to an actor is.

Routers are:

Messages can be sent via a router to efficiently route them to destination actors, known as its routees. A Router can be used inside or outside of an actor, and you can manage the routees yourselves or use a self contained router actor with configuration capabilities. But it sounds an awful lot like a dispatcher.

Pools are:

[A type of] router [that] creates routees as child actors and removes them from the router if they terminate.

Groups are:

[A type of] actor [where routees] are created externally to the router and the router sends messages to the specified path using actor selection, without watching for termination.

Event Buses are:

...a way to send messages to groups of actors

This sounds just like dispatchers and routers.

So my main concerns are:


Answer:

A dispatcher is basically a thread-pool. Akka uses dispatcher for multiple things (like enqueueing messages in the right mailbox or pick up a message from an actor mailbox and process it). Every time one of these actions need to be performed a thread from the thread-pool is selected and used for it. Akka comes by default with a default-dispatcher with the config you can find here in reference.conf searching for default-dispatcher. You are already using the default-dispatcher but you can define a different dispatcher to ensure you have a reserved thread-pool for other purposes (for example for the netty threads when using akka-remote or akka-cluster).

A router in Akka is an actor that uses some kind of routing logic to route messages to a list of routees. There are many types of router depending on the logic: Broadcast, Balancing, RoundRobin... you can find all of them in the akka docs. The routees of the router can be a pool or a group. One of the most popular use cases of routers is to vertically scale your app which means maximize the use of all the CPU available in your system (using multiple threads at the same time).

A pool means that the routees are being created on-demand for a given type. For example you may want a RandomPool of MyFancyActor with 3 instances. Akka will create three actors of MyFancyActor and a fourth one that will be the actual router. Every time the router actor gets a message will be forwarding the message to one of the 3 MyFancyActor actors. A pool takes care of restarting actors and watch their lifecycle to ensure you have n number of instances running.

A group means that the routees are being created before you are defining the router. Once you are defining your router you will need to pass a list of your routees actor that you previously created. A group will not monitor the lifecycle of your actors and you will need to do this yourself.

Event buses are channels where you can subscribe for a particular type of message with an actor. If there is a message of that particular type, you actor will get it. This is used for some Akka internals like subscribing to DeadLetters when a message is unable to reach its destination or events regarding the formation of a cluster (in akka-cluster). You will use this to be aware of events happening in your ActorSystem.


Related:


Does it make sense to watch(self) in akka?


akka
As far as I understand, context.watch simply delivers actor.Terminated message to watcher. I wanted it to be the last message that actor receives. Yet, I see that it is never delivered. I guess it can be because it is terminated and does not process messages anymore. As part of the...

Multiple routes with multiple domains


symfony2,routing
Let's say I've got a website with multiple (sub)domains: acme.com (USA) acme.nl (Netherlands) be.acme.eu (Belgium) de.acme.eu (Germany) fr.acme.eu (France) etc... I thought this should be very simple to configure, so I made this routing.yml: usa: host: "acme.com" resource: "@WebsiteBundle/Controller/" type: annotation defaults: country: "en" netherlands: host: "acme.nl" resource: "@WebsiteBundle/Controller/" type:...

Spark,Akka,Storm Or RxJava [closed]


apache-spark,akka,storm,rx-java,spark-streaming
I have a use case where I get 10K to 15 K Messages/sec and it might be less than 5K also sometime and I push those into rabbitMQ now those messages I should parse,run some RE on that and do some sort aggregation and run some statistics. My product(the data...

$StateProvider Remove Child View Nesting


angularjs,routing,angular-ui-router,angularjs-ui-router
I am new to angular ui routing . I am creating a sample application and want to display parent and child view separately . I mean when parent item gets selected child view will be displayed and parent view would be hidden . If I add ui-view to parent view...

Bulkheading strategies for Akka actors


java,asynchronous,akka,blocking,future
I have a scenario where an important actor needs to make a call to a slow (15 - 20 seconds) remote system: // Non-actor code equivalent public Result makeSlowNetworkCall(Request request) { Result result = slowServiceClient.soooooSlow(request); // Could be up to 15 - 20 SECONDS (mehhhh) return result; } The Akka...

How to use the Akka ask pattern without blocking


scala,asynchronous,akka,future
Hi I have a actor which is responsible for fetching data from a database, turning it into a list and sending it back to the sender. I am using the ask pattern to receive response from my actor, because I don't want to use await.result because this approach will block...

Rails routing link to specific show


ruby-on-rails-4,routing
This question seems a little basic, but considering I have 'pages#show' with a show page with url 'history'. How could I add this specific show page to a link: = link_to 'History', pages_path(@?????) PD1: I would prefer avoid using :id since I tend to seed a lot of data, and...

Select Mongoose Model Based on Express Route


express,routing,mongoose
I think this might be a basic question, but looking for the best approach. I'm building an express app that should route to one of four different Mongoose models depending on the route. Something like this: app.get('/:trial', function(req, res){ var trial = req.params.trial; trial.find(function(err, records) { if (err) res.send(err); res.json(records);...

Ruby-on-Rails Voting Partial Routing


ruby-on-rails,routing,voting
I have a voting feature on my app but can't route back to the same page with the vote applied. I know I have to fill in the link_to methods but my understanding of routing/ruby syntax is a bit limited, so I'm not even sure [post, vote] is correct. I...

How to add menus/ subtopics for meteor site?


javascript,node.js,meteor,routing,meteor-blaze
I am new to meteor. I followed the tutorials and successfully making simple interfaces like below. I tried finding examples to add menus/ subtopics like this which does not reload the page when clicked, but I couldn't find any examples. Could you please give me an example how to do...

Why does this MVC action return a 404 response in IE11


ajax,asp.net-mvc,routing
I have written an mvc action that works in Chrome and Firefox but not in IE11. Using IE11 it returns a 404 response code. Controller: [HttpDelete] public ActionResult DeleteAction(int ActionID) { return Json(_Logic.DeleteAction(ActionID), JsonRequestBehavior.DenyGet); } Calling JS: Ajax_Proxy.DeleteAction = function (_actionID, successCallback, failureCallback) { return $.ajax({ type: "DELETE", datatype: 'json',...

Spray microservice assembly deduplicate


scala,sbt,akka,spray,microservices
I'm using this template to develop a microservice: http://www.typesafe.com/activator/template/activator-service-container-tutorial My sbt file is like this: import sbt._ import Keys._ name := "activator-service-container-tutorial" version := "1.0.1" scalaVersion := "2.11.6" crossScalaVersions := Seq("2.10.5", "2.11.6") resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases" libraryDependencies ++= { val containerVersion = "1.0.1" val configVersion = "1.2.1"...

Spray Dead Letter msg


scala,akka,actor,spray
I'm trying to execute the following code trait CustomHttpService extends HttpService { import MyJsonProtocol._ import spray.httpx.SprayJsonSupport._ implicit def executionContext = actorRefFactory.dispatcher implicit val timeout = Timeout(5 seconds) val offerActor = actorRefFactory.actorOf(Props[OfferActor], "offer-actor") val defaultRoute = { path("offer" / JavaUUID) { uuid => get { respondWithMediaType(`application/json`) { complete { (offerActor ?...

Call Redis (or other db) from within Spray Route


scala,akka,spray,jedis
I am trying to figure out the best way to establish a Redis Pool and then make calls to Redis from within a Spray route. I want to make sure that I can use the connection pool for Redis connections. What would be the best way to instantiate the pool...

Route parameter with slash “/” in URL


asp.net-web-api,routing,asp.net-web-api2,asp.net-web-api-routing,attributerouting
I know you can apply a wildcard in the route attribute to allow / such as date input for example: [Route("orders/{*orderdate}")] The problem with wildcard is only applicable to the last paramter in URI. How do I solve the issue if want to have the following URI: [Route("orders/{orderdate}/customers")] ? EDIT:...

Akka consolidate concurrent database requests


scala,akka,spray
I want to be able to make concurrent requests to multiple data repositories and consolidate the results. I am trying to understand if my approach is at all valid or if there is a better way to approach this problem. I am definitely new to Akka / Spray / Scala...

Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef


scala,akka,akka-stream
I'm trying to use the Source.actorRef method to create an akka.stream.scaladsl.Source object. Something of the form import akka.stream.OverflowStrategy.fail import akka.stream.scaladsl.Source case class Weather(zip : String, temp : Double, raining : Boolean) val weatherSource = Source.actorRef[Weather](Int.MaxValue, fail) val sunnySource = weatherSource.filter(!_.raining) ... My question is: how do I send data to...

What is the best way to work with akka from nodejs


node.js,scala,express,akka
I have an application frontend, implemented on angularjs + nodejs + express + socket.io. There's also a feature in a separate service. This service is written on akka. Here's the way of how the entire communication pipeline may look: [user enters a value] -> [angularjs gets the value and send...

Spray route get response from child actor


scala,akka,spray
I am trying to figure out how I can setup a Master Actor that calls the appropriate children, in support of some spray routes where I am trying to emulate db calls. I am new to akka / spray, so just trying to gain a better understanding of how you...

scala minecraft forgemod 'gradle runClient' gives runtime exception


scala,gradle,akka,minecraft,minecraft-forge
I'm trying to use akka inside my scala based mod. The when testing using "gradle runClient" it gives errors, best I can tell its missing the akka library at runtime. I don't see how to add akka library though. If it helps my project is here: https://github.com/tesract/NilCraft Any advice would...

I don't understand routing


php,routing,flightphp
I am trying to learn a PHP framework. But I'm having some difficulties understanding some of the concepts of routing. I've chosen to use Flight. Their homepage shows: require 'flight/Flight.php'; Flight::route('/', function(){ echo 'hello world!'; }); Flight::start(); And I don't understand what they're using Flight::route... for. What am I missing?...

Is it possible in laravel 5 to show a pretty url to the user, and a practical url to the app?


routing,routes,laravel-5,friendly-url,slug
I have this url: mywebsite.com/user/1/edit I want my users to see this: mywebsite.com/edit-your-profile/ Is this possible when using Route::resource('user', 'UserController');? If yes, how do I do it :) ? I still want my app to be able to see user/1/edit as I use it in my middleware to prevent unauthorized...

Akka cluster and OpenShift


scala,akka,openshift
I'm new to Akka Clusters, however as I am understanding its documentation, I need to know at least one "seed node" to join an existing cluster. So when using clusters with OpenShift I would need to know if the current gear is the first node - then I would create...

WebApi Routing not working for Post


routing,asp.net-web-api2,asp.net-web-api-routing
My WebApiConfig has following routes // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { controller = "Employee", action = "Get", id = RouteParameter.Optional } ); The Post WebApi method has got following Signatures [HttpPost] public IHttpActionResult Post(Employee emp) { ..... } When i try to call...

How to change HTTP status code of AsyncResult using Scalatra


scala,akka,scalatra
I have created a simple controller (the code below is obfuscated and simplified, assume ask returns a future with a message). What I am trying to do is change the HTTP code from something other than 200 (based on the actor result). When executing the code below I see the...

Akka clustering conflicts


akka,zeromq,distributed-computing
The Akka doc talks about a variety of seemingly inter-related Akka technologies without distinguishing much between them: Akka Networking Akka Remoting Akka Clustering The Akka ZeroMQ module My understanding is that "Akka Networking" is simply a module/lib that gives Akka the ability to speak to remote actor systems over TCP....

Akka actorSelection vs actorOf Difference


scala,akka,actor
Is there a difference between these two? When I do: context.actorSelection(actorNameString) I get an ActorSelection reference which I can resolve using the resolveOne and I get back a Future[ActorRef]. But with an actorOf, I get an ActorRef immediately. Is there any other vital differences other than this? What might be...

Restrict laravel to open url that is not in route


php,laravel,routing,laravel-5,laravel-5.1
I am Learning laravel now. Today I came across a problem that surprised me. I open this link in my browser: http://localhost/laravel/project/ch/resources/views/pages/blog.blade.php And I expect error 404. but it opens contains of this file. So, How to restrict laravel to do this. I want laravel to open only url mentioned...

Modern Akka DI with Guice


java,akka,guice
Java 8, Guice 4.0 and Akka 2.3.9 here. I am trying to figure out how to annotate my actor classes with JSR330-style @Inject annotations, and then wire them all up via Guice. But literally every single article I have read (some examples below) either uses Scala code examples, a criminally-old...

No action was found on the controller that matches the request


c#,asp.net,ajax,asp.net-mvc,routing
Sorry for the lame question. I've already read all similar questions and still can't resolve my issue. I'm getting 'No action was found on the controller that matches the request' error when calling from ajax: $.ajax({ url: '/api/ToyEdit/Post/', dataType: "json", type: "POST", contentType: 'application/json; charset=utf-8', data: JSON.stringify({toyId: 1, toy: 'asd'}),...

How to deal with extra “/” in phpleague route?


php,web-services,routing
I am setting endpoints for my web application like this: $router = new League\Route\RouteCollection; function user_action (Request $request, Response $response) { // some logic . . . return $response; } $router->addRoute('GET', '/user', 'user_action'); /user endpoint works well. However when I use /user/ (extra slash in the end) I get a...

Re-transmission concept in TCP


tcp,routing,tcp-ip,osi
Server sent data to client, but client didn't send ACK for the data . So once RTT completed , Server will resend data to client again .... like that how long it will try to send the data ? What is the maximum time server will try to send the...

Symfony/Twig how to render a Route set by anotation?


php,symfony2,routing,twig,url-routing
Let's say I have this code in a controller: <?php namespace Foo\BarBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration as Mvc; /** * @Mvc\Route("/foo/bar") */ class TestController extends Controller /** * @Mvc\Route("/test/{id}", requirements={"id" = "[0-9]{1,6}"}) * @Mvc\Template * * @return view */ public function testAction($id) { return array('test' => $id); } } How...

Akka supervisor on stop of subordinate


scala,akka
I'm using Akka 2.3.11 and SupervisorStrategies for handling failures in the actors subordinates. However in addition to the supervision strategy I want to catch all "stops" (planned stops and such one which occur because of exceptions) of a subordinate to persist some information in the backends database. How can I...

akka: pattern for combining messages from multiple children


scala,concurrency,mapreduce,akka
Here's the pattern I have come across: An actor A has multiple children C1, ..., Cn. On receiving a message, A sends it to each of its children, which each do some calculation on the message, and on completion send it back to A. A would then like to combine...

How to access UrlHelper.Action or similar from within Global asax


c#,routing,asp.net-mvc-5
I am trying to prepare a 301 redirect for a typo I made 'recieved' I am struggling to find a way of getting the url from the action and controller names. I am aware of UrlHelper.Action but it does not exist within Global.asax. How do I gain access to this...

How to keep Akka running all the time in Play 2.3


playframework,playframework-2.0,akka
I am using akka as a scheduler in a website written with Play framework 2.3. I kept the server running by using activator run in dev environment. And when I changed some files and tried to visit my website, the Play server will compile these changed files and reload the...

Dynamic growth of `Actor`s vs Primal creation


scala,akka
In my project, I have defined groups of Actors called cells. Those cells process messages and operate basic calculations of some different kinds, one kind by small Actor type. What is the advantage(s) of growing those small Actors, then killing them once the job is done, rather than creating them...

Akka: multiple dispatcher vs multiple actor system


akka,spray
I am wondering what would be the criteria to choose between having several actor systems in one application over having multiple dispatcher ? What are the consequence of multiple actor system vs multiple dispatcher ? ( or advantage)...

Where should I put Symfony third-party bundle's routing configuration?


php,symfony2,routing,symfony-routing
I have SonataAdminBundle, SonataUserBundle and LiipImagineBundle installed in my Symfony 2 application. According to their installation instruction, I put their routing configuration in /app/config/routing.yml. _liip_imagine: resource: "@LiipImagineBundle/Resources/config/routing.xml" admin: resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml" prefix: /admin _sonata_admin: resource: . type: sonata_admin prefix: /admin sonata_user: resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml' prefix: /admin...

Open page url in modal on a page (Facebook Photo URLs)


javascript,jquery,angularjs,routing,angularjs-routing
P.S. I am using html5Mode to remove '#' in routing in below scenario Removing the hashtag from AngularJS urls (# symbol) Consider I have two main pages.One is photos where thumbnails are provided and whose url is /someSlug/photos. Other is the url of a single photo '/someSlug/photos/somePhotoId' which shows a...

Asp.net MVC Routelink null controller parameter


c#,asp.net,asp.net-mvc,asp.net-mvc-4,routing
I have two routes, the default one routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); I added another route, sometimes the parameter will by a string routes.MapRoute( name: "ByName", url: "{controller}/{action}/{name}", defaults: new { controller = "Home", action =...

Convert existing SBT Scala application to Play


scala,playframework,sbt,akka
I've been working on building an application with Akka actors, and now that I've completed the actor-based business logic I'd like to give it a RESTful + websocket front-end. I'm trying to find instructions for how to setup Play within the context of an existing application. The only instructions I...

Codeigniter Select JSON, Insert JSON


json,codeigniter,select,insert,routing
I have very simple users database: user_id, user_name, user_email My model this: class Users extends CI_Model { private $table; private $table_fields; private $table_fields_join; function __construct() { parent::__construct(); $this->table = 'users'; $this->table_fields = array( $this->table.'.user_id', $this->table.'.user_name', $this->table.'.user_email' ); $this->table_fields_join = array(); } function select(){ $this->db->select(implode(', ', array_merge($this->table_fields, $this->table_fields_join)));...

Change resources path


ruby-on-rails,ruby,routing
I'm using Rails 4 I have a routes.rb file that looks like: resources :books However, I'd like the urls in the application to end up looking like /b/101 instead of /books/101. I realize I could go through and rename each resource path individually, but is there not a way to...

Combining Spray Routing + Actor Pattern Matching


scala,akka,spray,akka-cluster
Following the Akka Cluster documentation, I have the Worker Dial-in example running. http://doc.akka.io/docs/akka/snapshot/java/cluster-usage.html So I've trying to integrate that with a spray routing. My idea is to have a cluster behind the scenes and through a http rest, call that service. So I have the following code. object Boot extends...

Angular $routeProvider and Controller As Syntax


angularjs,routing,angularjs-scope,angularjs-routing,ngroute
Can anyone tell me if it is valid to use $routeProvider with Controller as syntax? I am having issues accessing <h1>{{kickController.foo}}</h1> from the controller where this.foo resides. angular.module('ucp.kick', ['ngRoute']).config(function($routeProvider, APP_BASE_URL) { return $routeProvider.when(APP_BASE_URL + 'kicks', { reloadOnSearch: false, navitem: true, name: 'Kicks', templateUrl: 'kick/partials/kick.html', controller: 'kick as KickController' }); });...

Node forward path request to another server


node.js,express,routing,routes,request
Currently have a website running a node server that handles all requests for example.com and I created a completely separate wordpress blog on a separate server (running apache) that I would like served on a path like example.com/blog at 172.23.23.23 IP address. The wordpress server doesn't share any code or...

ActorNotFound Exception trying to run Spark 1.3.1 on windows 7


apache-spark,akka
We are at a road block trying to understand why Spark 1.3.1 doesn't work for a colleague of mine on his Windows 7 laptop. I have pretty much the same setup and everything works fine for me. I searched for the error message but still didn't find a resolution. Here...

SAPUI5/OPENUI5 - Routing with Dialogs


routing,dialog,sapui5,openui5
I´m currently stuck with the combination of routing and dialogs. I have a view with list elements and when I click on an element in the list I want the Detail view to be shown in a Dialog (Popup). The thing is, I also want the ID of the list...