What is a Message Broker for?

Source: Pexels.com

I’ve been working in tech for a few years now, and that’s included writing a lot of code.

One thing I never got my head around was what is a message broker? I’ve definitely seen them in architecture meetings, and heard people speak of ‘RabbitMQ’ and ‘Redis’ but I don’t really know what they’re for.

So here’s my explanation.

A message broker is like a postoffice

A message broker: is a bit like a letter, a post office and a postman all in one.

It accepts and forwards messages. The messages get produced by a ‘producer’ and put onto a ‘queue’ and then collected by a ‘consumer’.

One reason you may want to do this is that you may want to store calculations made by a prediction server in a queue, and then have a web server poll that, and then present the results to a user. The advantage of this is that you can decouple the functionality from the web server – say a prediction server.

Other use cases

  • What about when your organization wants to work with the new Internet of Things (IoT). Then you would have thousands of devices, but how do you manage the data of all those devices? Well this is where a Message Broker also excels in. Just send all your data of these devices towards your Message Broker, and it will take care of processing them.

A nice use case from – this article

  • Running Redis on our machine
  • Queuing up data (images) to our Redis store to be processed by our REST API
  • Polling Redis for new batches of input images
  • Classifying the images and returning the results to the client

So there you have it, you may often want to queue up data to be processed, and you may not want to do it all at once. This is a very powerful technique for helping you build performant and scalable applications.

Is there something I’ve missed? Let me know on Twitter if I’m wrong

Leave a Reply

Your email address will not be published.