-
-
Save kares/c9e303c0d34c819bc675f463095e21f5 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
input { | |
rabbitmq { | |
codec => plain | |
host => "localhost" | |
key => "#" | |
exchange => "sysmsg" # string (optional) | |
queue => 'dur-no-policy-4' | |
durable => true | |
threads => 1 | |
prefetch_count => 50 | |
} | |
} | |
output { | |
stdout { codec => rubydebug } | |
} |
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
require 'march_hare' | |
conn = MarchHare.connect(:host => "localhost") | |
ch = conn.create_channel | |
exchange = ch.direct("sysmsg", :durable => true) | |
#exchange = ch.direct("sysmsg") | |
puts "exchange: #{exchange}" | |
#queue = ch.queue("ls-dur-1", :auto_delete => false, :durable => true).bind(exchange, :routing_key => "temp") | |
#queue = ch.queue("ls-dur-1", :durable => true).bind(exchange, :routing_key => "#") | |
#queue = ch.queue("non-dur-2", :durable => false).bind(exchange, :routing_key => "#") | |
#queue = ch.queue("non-dur-3", :durable => false) | |
#queue = ch.queue("ls-dur-2", :durable => true) | |
#queue = ch.queue("ls-dur-3", :durable => true).bind(exchange, :routing_key => "#") | |
queue = ch.queue("dur-no-policy-4", :durable => true).bind(exchange, :routing_key => "#") | |
puts "queue: #{queue}" | |
begin | |
i = 0 | |
while(true) | |
print "." | |
#exchange.publish("X#{(i += 1)}", :routing_key => "#") | |
queue.publish("Y#{(i += 1)}", :routing_key => "#") | |
sleep 0.25 | |
(sleep 3.5; puts "\n") if i > 0 && i % 100 == 0 | |
end | |
ensure | |
# we do not want to delete (durable) queue/exchange on the server | |
# 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