A synchronous amqp client
Ruby
Latest commit fd16e38 Feb 1, 2016 @famoseagle Merge pull request #10 from yammer/frame_max
Handle the frame_max option when negotiating the connection with the server
Failed to load latest commit information.
lib handle the frame_max option when negotiating the connection with the … Feb 1, 2016
protocol adding aman's amqp code Mar 20, 2009
test fixed tests Aug 3, 2011
.gitignore Initial commit to carrot. Mar 20, 2009
LICENSE adding examples and readme Apr 8, 2009
README.markdown Added a usage example Oct 30, 2013
Rakefile fixed tests Aug 3, 2011
VERSION.yml
carrot.gemspec Regenerate gemspec for version 1.2.0 Oct 20, 2011

README.markdown

Carrot

A synchronous amqp client. Based on Aman's amqp client:

http://github.com/tmm1/amqp/tree/master

Motivation

This client does not use eventmachine so no background thread necessary. As a result, it is much easier to use from script/console and Passenger. It also solves the problem of buffering messages and ack responses. For more details see this thread.

There is currently no way to prevent buffering using eventmachine. Support for prefetch is still unreliable.

Examples

require 'carrot'

q = Carrot.queue('name')
10.times do |num|
  q.publish(num.to_s)
end

puts "Queued #{q.message_count} messages"
puts

while msg = q.pop(:ack => true)
  puts "Popping: #{msg}"
  q.ack
end
Carrot.stop

Using options with server and queue

require 'carrot'

c = Carrot.new
q = c.queue('queue_name', {
  host: 'example.com',
  user: 'username',
  pass: 'passwd',
  vhost: '/',
  auto_delete: true
})
c.direct("name.exchange", { :durable => true })

10.times do |num|
  q.publish(num.to_s, {persistent: true, no_wait: false})
end

puts "Queued #{q.message_count} messages"

while msg = q.pop(:ack => true)
  puts "Popping: #{msg}"
  q.ack
end
c.stop

LICENSE

Copyright (c) 2009 Amos Elliston, Geni.com; Published under The MIT License, see License