Last active
June 2, 2021 10:28
-
-
Save andsel/1d3a734337d29023680ac9a5cd349d18 to your computer and use it in GitHub Desktop.
Simple RabbitMQ sender
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
#run dockerized RabbitMQ | |
# docker run -v rabbitmq-data:/var/lib/rabbitmq --hostname my-rabbit --name rabbit_dev -p 15672:15672 -p 5672:5672 rabbitmq:3-management | |
# navigate to http://localhost:15672/#/queues | |
# login guest:guest | |
require 'march_hare' | |
conn = MarchHare.connect(:host => "localhost") | |
ch = conn.create_channel | |
exchange = ch.direct("sysmsg", :durable => true) | |
queue = ch.queue("iot_queue", :auto_delete => false, :durable => true).bind(exchange, :routing_key => "temp") | |
puts "Queue created" | |
begin | |
while(true) | |
puts "." | |
exchange.publish("27C", :routing_key => "temp") | |
sleep 0.5 | |
end | |
ensure | |
puts "cleanup" | |
exchange.delete | |
queue.delete | |
ch.close | |
conn.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment