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

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 Lead Consultant, with experience of more than 7 years. Rishi is product focused developer who loves developing both front-end user interfaces and scalable back-end infrastructure. He is a good team player, quick learner and a humble person. He has good time management skills, aimed to give best results and fully dedicated towards his work & responsibilities. He is able to work as individual and as well as in team. He loves to share his knowledge, therefore he often writes technical blogs.

1 thought on “One-way & two-way streaming in a Lagom application

Leave a Reply

%d bloggers like this: