Distributed Message Queues in Ruby on Rails
what’s message queue?
Learn Ruby on Rails - Ruby on Rails tutorial - message queue - Ruby on Rails examples - Ruby On Rails programs
Distributed Message Queues
- Starling
- AMQP/RabbitMQ
- Stomp/ActiveMQ
- beanstalkd
Why not DRb?
- DRb has security risk and poorly designed APIs
- Distributed message queue is a great way to do distributed programming: reliable and scalable.
Starling
- A light-weight persistent queue server that speaks the Memcache protocol (mimics its API)
- Fast, effective, quick setup and ease of use
- Twitter’s open source project, they use it before 2009. (now switch to Kestrel, a port of Starling from Ruby to Scala)
Starling command
- sudo gem install starling-starling
- sudo starling -h 192.168.1.100
- sudo starling_top -h 192.168.1.100
Starling set example
Starling get example
get method
- FIFO
- After get, the object is no longer in the queue. You will lost message if processing error happened.
- The get method blocks until something is returned. It’s infinite loop.
Handle processing error exception
Starling cons
- Poll queue constantly
- RabbitMQ can subscribe to a queue that notify you when a message is available for processing.
AMQP/RabbitMQ
- A complete and highly reliable enterprise messaging system based on the emerging AMQP standard.
- Erlang
Stomp/ActiveMQ
- Apache ActiveMQ is the most popular and powerful open source messaging and Integration Patterns provider.
- sudo gem install stomp
- ActiveMessaging plugin for Rails
beanstalkd
- Beanstalk is a simple, fast workqueue service. Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.