Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fill up pg2table in RabbitMQ
#!/usr/bin/env ruby
require 'bunny'
require 'dotenv/load'
connection = Bunny.new ENV['CLOUDAMQP_URL3']
connection.start
channel = connection.create_channel # Declare a channel
for i in 1..1
puts "Creating queue #{i}"
queue = channel.queue("", :exclusive=> true, :arguments => { "x-message-ttl" => 2000 , "x-expires"=>10000})
# publish 1 messsage to the queue
x = channel.default_exchange
x.publish("Message #{i}", :routing_key => queue.name)
end
sleep(15)
connection.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment