Created
December 12, 2017 12:50
-
-
Save caius/0d8f03098b990cd661f22b0dae3206be to your computer and use it in GitHub Desktop.
This file contains hidden or 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_relative "./shared" | |
seen_ids = [] | |
$q.subscribe(:block => true, :manual_ack => true) do |delivery_info, metadata, payload| | |
data = JSON.parse(payload) | |
p "Got #{data["id"]} (#{data["nack"]})" | |
if seen_ids.include?(data["id"]) | |
raise "Dup! Already seen this message" | |
end | |
seen_ids << data["id"] | |
if data["nack"] | |
$channel.nack(delivery_info.delivery_tag, false, true) | |
else | |
$channel.ack(delivery_info.delivery_tag) | |
end | |
end |
This file contains hidden or 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_relative "./shared" | |
1.upto(Float::INFINITY) do |i| | |
payload = { | |
:id => i, | |
:nack => (i == 2) | |
} | |
$x.publish(payload.to_json, :routing_key => $q.name) | |
end | |
$conn.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment