JavaUser
JavaUser

Reputation: 26324

Inter process(service) communication without message queue

We want to develop an application based on micro services architecture. To communicate between various services asynchronously, we plan to use message queues(like RabbitMQ,ActiveMQ,JMS etc.,) . Is there any approach other than message queue is available to achieve inter process communication?

Thanks.

Upvotes: 1

Views: 1445

Answers (1)

Ujjaval Moradiya
Ujjaval Moradiya

Reputation: 222

You should use Queues to handle the tasks that needs not to be completed in real time.

Append the tasks in queue and when there is a room, processor will take tasks from queue and will handle & will remove from queue.

Example :

  1. Assuming your application deals with images, users are uploading so many images. Upload the tasks in a queue to compress the images. And when processor is free it will compress the queued images.

  2. When you want to write some kind of logs of your system, give it to the queue and one process will take logs from queue and write that to disk. So the main process will not waste its time for the I/O operations.

Suggestion :

If you want the real time responses, you should not use the queue. You need to ping the queue constantly to read the incomings, and that is bad practice. And there is no guarantee that queue will handle your tasks immediately.

So the solutions are :

  1. Redis cache - You can put your messages into cache and other process will read that message. Redis is "In memory data-structure". It is very fast and easy to use. Too much libraries and good resources available on the Internet, as it is open source. Read more about Redis. But here you also need to keep check whether there is some kind of message available and if available read from it, process and give response. But to read from Redis, is not very much costlier. With redis, you do not need to worry about memory management, it is well managed by open source community.

  2. Using Sockets. Socket is very much faster, you can make this lightweight(if you want) as it is event based. One process will ping on port and other process will listen and give response. But you need to manage memory. If the buffered memory gets full, you can not put more messages here. If there are so many users producing messages, you need to manage to whom to you want to respond.

So it depends upon your requirement, like do you want to read messages constantly?, do you want to make one to one communication or many to one communication?

Upvotes: 1

Related Questions