Skip to content

Instantly share code, notes, and snippets.

@johanrhodin
Last active November 10, 2020 14:05
Show Gist options
  • Save johanrhodin/8a259e2a3b750159fcea9fea32fb41b2 to your computer and use it in GitHub Desktop.
Save johanrhodin/8a259e2a3b750159fcea9fea32fb41b2 to your computer and use it in GitHub Desktop.
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