Created
June 3, 2016 16:30
-
-
Save richardlarocque/c3f1c1b4cae748f9c31f8330ed641089 to your computer and use it in GitHub Desktop.
RabbitMQ delayed exchange test script
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 | |
# Based on the script posted at to https://groups.google.com/forum/#!topic/rabbitmq-users/XgjY7UtLkfs | |
# | |
# Usage: ./push_rammitmq [DELAY_MS] [MESSAGE_COUNT] | |
require 'bunny' | |
bunny = Bunny.new("amqp://localhost:5672/", vhost: "/", recover_from_connection_close: true) | |
bunny.start | |
channel = bunny.create_channel | |
exchange = channel.exchange("test-delayed-exchange", type: "x-delayed-message", arguments: { "x-delayed-type" => :direct }) | |
queue = channel.queue("test-delayed-queue") | |
queue.bind("test-delayed-exchange", routing_key: "test-routing-key") | |
queue.purge | |
delay = ARGV[0].to_i | |
count = ARGV[1].to_i | |
t0 = Time.now | |
puts "Starting around #{t0}" | |
count.times do |i| | |
channel.basic_publish("[]", "test-delayed-exchange", "test-routing-key", headers: { "x-delay" => delay }) | |
if i % 10000 == 0 | |
puts "#{Time.now}, #{Time.now - t0}, #{i}" | |
end | |
end | |
puts "Took #{Time.now - t0}" | |
bunny.stop | |
puts "Finished #{Time.now - t0}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment