Created
March 12, 2019 16:06
Starting point to create RabbitMQ exchanges and queues with ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding utf-8 | |
require 'bunny' | |
STDOUT.sync = true | |
conn = Bunny.new(host: 'rmq', user: 'guest', pass: 'guest') | |
conn.start | |
ch = conn.create_channel | |
x = ch.direct('work.exchange') | |
dlx = ch.direct('retry.exchange') | |
target_queue = ch.queue('work.queue', arguments: { | |
:'x-dead-letter-exchange' => 'retry.exchange' | |
}).bind(x, routing_key: 'work.queue') | |
retry_queue = ch.queue('retry.queue', arguments: { | |
:'x-dead-letter-exchange' => 'work.exchange', | |
:'x-message-ttl' => 60000 | |
}).bind(dlx, routing_key: 'work.queue') | |
conn.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment