In my previous blog, I explained how you can implement WebSocket server using Akka-HTTP. As you know, Microservice architecture has become very popular in recent years. This architecture fits perfect
1) When you want to give support of your application for many platforms such as web, mobile etc.
2) When your application consists of multiple services such as order service, account service, payment service etc.
In this blog, I have explained a simple example of WebSocket based Microservice Architecture using Akka-HTTP in Scala. You will see how WebSocket based Microservices can communicate with each other in a application.
In this example, there are two sub modules Account for Account related services and Order for Order related services. There is one more sub module Api, which will forward coming requests to their corresponding services.
build.sbt for this multi module project.
Now create routes and its handler for Account service:-
Create routes and handler for Order service:-
Create routes and handler for Api service:-
You can find complete code here.
To run this example:-
– Open 3 terminals
– Execute `sbt “project api” run` from first terminal.
– Execute `sbt “project account” run` from second terminal.
– Execute `sbt “project order” run` from third terminal.
– Download `Dark Websocket terminal` web socket client extension of google chrome
You can find complete detail here to use this project.
1 thought on “A Simple Example of WebSocket based Microservice Architecure using Akka-HTTP in Scala1 min read”
Reblogged this on ayushkumarmishra.
Comments are closed.