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 it to nodejs server thru socket.io] -> [nodejs receives the value and channel it to akka] -> [akka performs some calculation and return a response] -> [nodejs receive the response and channel it to angularapp].
One possible solution would be to introduce a MQ middleware and use it for the interaction, but such "message driven approach" seems like an overhead for something that clearly looks like an RPC call. What is the best way to build up such type of communication between nodejs and akka?
Akka is a truly reactive framework because everything in the sense of sending and receiving a message to Actors, is lock-less, non-blocking IO, and asynchronous.
Quick & easy development Node. js has large and active community that contribute many useful and mature modules which can be easily included and used. For example, to construct REST API such known modules as express, restify and hapi fit perfectly.
You can run Nodejs such as react or angular on JavaPipe's Tomcat service. You will need to use npm run build to package the Nodejs for production. It creates a build folder where you can package it as a war file. cd into the build directory and then run jar cvf webui.
Since Akka speaks HTTP itself you can just make a RESTful call from Node to the Akka service. Pipelining is supported so you can make this very efficient. Within the Akka HTTP server flow you use the ask pattern to get the calculated value back from your actor.
The cleanest way would to be to skip node.js
/socket.io
for the messaging layer and instead use websockets over spray.io
directly. Typesafe has an activator template for just the scenario of websockets to akka actors: Spray and Websocket interfaces to actors
Otherwise you would be looking at some kind of RPC middleware, maybe Thrift or ZeroMQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With