Carrot
A synchronous amqp client
Install / Use
/learn @famoseagle/CarrotREADME
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
Related Skills
node-connect
349.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.7kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
