At CloudAMQP, we believe that working with message queues should be intuitive and enjoyable. On that note, we're thrilled to announce a major step in this vision: the launch of amqp-client.rb version 2.0! This release completely re-imagines how Ruby developers interact with AMQP brokers, delivering the clean, powerful experience we've always envisioned. To understand the limitations this new client seeks to overcome, let's look at the traditional AMQP approach.
The problem with traditional AMQP clients
If you've worked with AMQP, you know the drill. Managing connections, channels, delivery, and error handling adds up fast. Traditional clients require dozens of lines of boilerplate just to reliably send or receive a message.
While this low-level control suits advanced use cases, most developers want to move messages from A to B without wrestling with connection management or protocol specifications.
We want you to write code like this:
# Ruby - Publishing a message
client = AMQP::Client.new("amqp://localhost")
client.queue("my_queue").publish("Hello World")
# Ruby - Consuming messages
client.queue("my_queue").subscribe do |message|
puts "Received: #{message.body}"
end
Instead of managing connections, channels, exchanges, and all the underlying complexity yourself. Here's what the traditional approach looks like:
# Traditional low-level approach (amqp-client.rb 1.x)
require "amqp-client"
require "json"
require "zlib"
# Create and manage connection
connection = AMQP::Client.new("amqp://localhost").connect
# Create and manage channel
channel = connection.channel
# Declare exchange
channel.exchange_declare("my_exchange", "topic", durable: true)
# Declare queue
channel.queue_declare("my_queue", durable: true)
# Bind queue to exchange
channel.queue_bind("my_queue", "my_exchange", "routing.key")
# Publishing with confirmations, JSON serialization, and gzip encoding
channel.confirm_select
data = { message: "Hello World", timestamp: Time.now.to_i }
json_body = JSON.generate(data)
gzipped_body = Zlib.gzip(json_body)
properties = AMQP::Client::Properties.new(
delivery_mode: 2,
content_type: "application/json",
content_encoding: "gzip"
)
channel.basic_publish(gzipped_body, "my_exchange", "routing.key", properties: properties)
channel.wait_for_confirm
# Consuming with manual acks, decompression, and JSON parsing
channel.basic_consume("my_queue", no_ack: false) do |msg|
begin
# Decompress and parse the message
decompressed = Zlib.gunzip(msg.body)
data = JSON.parse(decompressed)
puts "Received: #{data}"
channel.basic_ack(msg.delivery_tag)
rescue => e
channel.basic_nack(msg.delivery_tag, requeue: true)
end
end
# Don't forget to clean up!
at_exit do
channel.close
connection.close
end
That's a lot of ceremony just to send and receive messages reliably, and this doesn't even begin to cover handling network errors, reconnections, and other edge cases! Our high-level clients handle all of this complexity behind the scenes.
amqp-client.rb 2.0: Our first major step
Version 2.0 refines and polishes the high-level API that was introduced in 1.x, making it even more intuitive and powerful:
- Refined high-level API - Even simpler method chaining and more intuitive queue/exchange operations
- Automatic message encoding/decoding - Built-in support for JSON, gzip, and deflate with extensible codec registry
- RPC Support - First-class abstractions for building RPC clients and servers over AMQP
- Automatic ack/reject - Safe defaults for message consumption with easy-to-use acknowledgment strategies
We are motivated to bring these improvements to our other client libraries as well.
What's coming next
We're not stopping with Ruby. We're actively working on bringing the same level of polish and developer experience to:
- amqp-client.js - JavaScript/TypeScript client
- amqp-client.cr - Crystal client
These updates will follow the same philosophy: eliminate boilerplate, provide safe defaults, and make AMQP development a joy rather than a chore.
Your language, our priority
We want to hear from you! Are you working in a language that doesn't have a great AMQP client? Would you love to see CloudAMQP build a high-level client library for your favorite programming language?
Whether it's Go, Python, Java, Rust, Elixir, or any other language, we're listening. The AMQP client ecosystem should have excellent options in every major language, and we're committed to making that happen.
Request work on the client for Your Language
The journey continues
Building great developer tools is an ongoing journey. We're committed to continuously improving our AMQP clients based on real-world usage and community feedback. The release of amqp-client.rb 2.0 is just the beginning.
As we roll out improvements to our other clients, and potentially expand to new languages, we'll keep the community updated through our blog and GitHub repositories.
Happy queuing!
Want to try CloudAMQP with our improved client libraries? Get started with a free plan and experience the difference that great tooling makes.