One-way & two-way streaming in a Lagom application

Table of contents
Reading Time: 2 minutes

Now a days streaming word is a buzz word and you should have heard many types of streaming till now i.e. kafka streaming, spark streaming etc etc. But in this blog we will see a new type of streaming i.e Lagom-streaming.

Lagom-streaming internally uses Akka streams, with the help of which we will see one way & two way streaming. But before going forward, it would be good we will get the difference between one way & two way streaming, so then lets get the difference first and then will move further.

One-way streaming: In this type of streaming, request will be normal but the response will be streamed.

Two-way streaming: In this type of streaming both request & response will be streamed.

Now as we have got the difference, I will not waste your time in theory part. Lets move ahead to see the implementation part in Lagom. We will see both type of streaming together so that we can compare those very easily and can understand the difference quite properly.

API implementation:

One-way streaming:

Two-way streaming:

Full code for API :


Service Implementation:
One-way streaming:

Two-way streaming:

Full code:

That’s it. We have implemented the streaming in a Lagom application.

But now the challenge is how to test this. We can not test this through postman or normal rest client, we need websocket client or application to test this. So either create n websocket client by yorself or use the online websocket client to test the streaming application.

I hope it will be worthy for you and you enjoyed the reading. You can get the full code here.


knoldus-advt-sticker


Written by 

Rishi is a tech enthusiast with having around 10 years of experience who loves to solve complex problems with pure quality. He is a functional programmer and loves to learn new trending technologies. His leadership skill is well prooven and has delivered multiple distributed applications with high scalability and availability by keeping the Reactive principles in mind. He is well versed with Scala, Akka, Akka HTTP, Akka Streams, Java8, Reactive principles, Microservice architecture, Async programming, functional programming, distributed systems, AWS, docker.

1 thought on “One-way & two-way streaming in a Lagom application3 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading