Queue Bus
At TaskRabbit, we have been using resque-bus for about two years. It has continued to provide value by linking components via a loosely coupled publish/subscription model. We have seen 10x the number of events going through it, but have not yet hit any scaling issues. The benefit of using the tools we already have continues to be a huge win.
But other teams are using other tools like Sidekiq. We’re also interested in trying it out, but resque-bus (unsurprisingly) was tied closely to Resque. We’ve changed that by creating queue-bus and using an adapter pattern. There are now adapters in resque-bus and sidekiq-bus, as well as a compatible version in node-queue-bus.
The code interactions are basically the same but can work across systems. You can even have one app using Resque and one using Sidekiq.
Pick your adapter
By requiring one of the adapters, it automatically gets set up to be the one for the app.
1
|
|
Application A publishes an event
Something happens in your application and you want to let the world know. In this case, you publish an event.
1 2 3 4 5 |
|
Application B subscribes to events
If the same or different application is interested when an event happens, it subscribes to it by name.
1 2 3 4 5 6 7 |
|
Upgrading
The formats changed a little bit with the move. The last version that used the old format (0.3.7) also can adapt to the new format. This is important because you’ll have things in the queue during the transition.
Steps:
- Upgrade everyone to 0.3.7
- Deploy all the things
- Upgrade everyone to the newest version
More to come
If people continue to like this approach and gem, we have lots of approaches and tools built on top of it that we’d be excited to make available. Let us know on Github that you like it by watching, starring, or creating issues with questions, etc.
Now that we have the adapter pattern, also let us know if you are interested in making one for your background system of choice. A special thanks goes out to Jonathan Greenberg and the team at purpose.com who did just that to get this whole thing going.