Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ instead of WebHooks

We have a project which provides API for a number of clients who are approved by us (we sign paper contracts with them). Our clients want to get updates from us about their resources (all clients are independent). Currently, we consider WebHooks and RabbitMQ to stream events. RabbitMQ sounds exotic since it will be used by external clients (yeah, we approve them, but we don't control them). If we go with WebHooks, we need to re-implement lots of features which we get for free from RabbitMQ.

Features we need to implement in case of WebHooks:

  • authentication and subscription (some clients have a few independent apps, so they need a way to tell us where their apps are)
  • signed requests (they need to be sure requests come from us)
  • a retry mechanism (we don't have to deal with it if we choose RabbitMQ)
  • a mechanism to guarantee the order of events (it is even more fun considering the retry mechanism. Again we don't need this if we choose RabbitMQ)
  • kind of topics, so they only get what they need

Have you heard about any experience of using RabbitMQ in place of WebHooks? Does it sound too crazy?

like image 527
Dmitriy Nesteryuk Avatar asked Oct 19 '25 01:10

Dmitriy Nesteryuk


1 Answers

If you want to send events through direclty RabbitMQ, you will face the following challenges:

  1. You have to send the same event to different queues in order for your clients only to receive their own events. E.x.: client1.invoice.paid, client2.invoice.paid

  2. You have to create an account in RabbitMq for each client, it will create the challenges of user management.

  3. Security. Your Rabbitmq service port is going to be open to the public.

In order to avoid those challenges, you should implement a webhook dispatch service with RabbitMq. How does it work?

  1. Send your event from the main app to RabbitMQ.
  2. Webhook service receives the event and sends it to the URL accordingly.

Check this URL to get an idea of how to design webhook service: https://www.slideshare.net/jbliao/how-to-design-reliable-and-scalable-webhooks-with-rabbitmq

like image 146
nsv Avatar answered Oct 22 '25 04:10

nsv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!