-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated amq-protocol.cr to v1.1.10 to fix issue. Also added spec.
- Loading branch information
1 parent
a4e10da
commit 45c2a2f
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "./spec_helper" | ||
require "./../src/lavinmq/queue" | ||
|
||
describe "Dead lettering" do | ||
q_name = "ttl" | ||
q_name_delayed = "ttl_delayed" | ||
q_name_delayed_2 = "ttl_delayed_2" | ||
|
||
# Verifies bugfix for Sub-table memory corruption in amq-protocol.cr | ||
# https://github.com/cloudamqp/amq-protocol.cr/pull/14 | ||
it "should be able to read messages that has been dead lettered multiple times" do | ||
with_channel do |ch| | ||
q_delayed_2 = ch.queue(q_name_delayed_2, args: AMQP::Client::Arguments.new( | ||
{"x-message-ttl" => 1, "x-dead-letter-exchange" => "", "x-dead-letter-routing-key" => q_name_delayed} | ||
)) | ||
q_delayed = ch.queue(q_name_delayed, args: AMQP::Client::Arguments.new( | ||
{"x-message-ttl" => 1, "x-dead-letter-exchange" => "", "x-dead-letter-routing-key" => q_name} | ||
)) | ||
q = ch.queue(q_name) | ||
|
||
x = ch.default_exchange | ||
x.publish_confirm("ttl", q_delayed_2.name) | ||
msg = wait_for { q.get } | ||
|
||
x_death = msg.properties.headers.not_nil!["x-death"].as(Array(AMQ::Protocol::Field)) | ||
x_death.inspect.should be_a(String) # checks that message and headers can be read | ||
x_death.size.should eq 2 | ||
x_death[0].as(AMQ::Protocol::Table)["queue"].should eq q_delayed.name | ||
x_death[1].as(AMQ::Protocol::Table)["queue"].should eq q_delayed_2.name | ||
end | ||
end | ||
end |