DEV Community

Pawan Chaurasia
Pawan Chaurasia

Posted on

Implementing Rails and RabbitMQ for EventDriven Architecture

Just to learn more about rails and event driven architecture I want to know how I can acieve that. Any person having past experince in implementing this or have a knowledge about system architecture and want to guide me thought this are welcome.
I would love to have a discussion on implemnting this.

Top comments (6)

Collapse
 
rhymes profile image
rhymes • Edited

Hi Pawan, making Rails talk to RabbitMQ is possible through bunny but:

  • maybe you don't need to talk directly to rabbitmq
  • rabbitmq is not that widespread as a service on the cloud which means you might need to learn how to configure it and set it up and it's not particularly easy

I'm saying this because I would like to understand what you're trying to accomplish before suggesting a direction or another.

At a high level of abstraction the easiest configuration I can come up with is the classical producer - queue - consumer:

  • your Rails web app produces data to process asynchronously
  • it puts such data on the queue
  • a consumer process takes it from the queue and works on it

This can get you far both with scaling and with load distribution.

Keep in mind that "event driven" is a more abstract concept, the UI I'm typing this in is event driven, every keyboard press generates an event (interrupt) that's processed by the operating system, sent to the application and then handled by a handler (the consumer) somewhere.

Collapse
 
pwnchaurasia profile image
Pawan Chaurasia

I am trying to implement pubsub (producer - queue -consumer). so that I can achieve the almost realtime data driven graphs.
I know few other options are redis and kafka for the same but we are going for RabbitMQ. I have already used redis. As a whole I will be implementing this on different stack to achieve microservices structure. Its just a beginner step towards that.

Collapse
 
rhymes profile image
rhymes

Ok, you might want to look into sneakers as well. It's a job processing framework that sits on top of Bunny and uses RabbitMQ as its backend.

Basically you submit jobs with bunny and/or consume them with sneakers

Thread Thread
 
tenzinisco profile image
Tenzin dorjee

@rhymes , So I am currently working on microservice based rails app, i used sneakers and bunny. I wanted to implement saga pattern using bunny and sneakers. Didn't know how to get started with saga pattern using bunny and sneakers. Any idea how?

Thread Thread
 
rhymes profile image
rhymes

Not really, since it seems to be a pattern not stricly dependent on Ruby/Rails, have you tried asking on StackExchange - microservices? you can also search for "saga" in there to see if you get any ideas.

Another option is to ask for help here ;-) I'd suggest adding the tags #help and #microservices to your post

Collapse
 
tweettamimi profile image
Tamimi

Hey Pawn! Just stumbled across your post and was wondering if you still want to start a discussion on building eventdriven applications? There are alot of tools and frameworks that makes it very easy to build a pubsub platform!