Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: DLX parameters aren't updated when the messages is expired #601

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions spec/dlx_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,47 @@ describe "Dead lettering" do

msg.timestamp.should be > ts
end

it "should update count in x-death" do
with_channel do |ch|
q_name = "q_dlx"
q = ch.queue(q_name, args: AMQP::Client::Arguments.new(
{"x-dead-letter-exchange" => "", "x-dead-letter-routing-key" => "#{q_name}2"}
))
_q2 = ch.queue("#{q_name}2", args: AMQP::Client::Arguments.new(
{"x-dead-letter-exchange" => "", "x-dead-letter-routing-key" => q_name, "x-message-ttl" => 1}
))

done = Channel(AMQP::Client::DeliverMessage).new
i = 0
q.subscribe(no_ack: false) do |env|
env.reject
if i == 10
env.ack
done.send env
end
i += 1
end
ch.default_exchange.publish_confirm("msg", q.name)

msg = done.receive
headers = msg.properties.headers.should_not be_nil
x_death = headers["x-death"].as?(Array(AMQ::Protocol::Field)).should_not be_nil
x_death_q_dlx_rejected = x_death.find do |xd|
xd = xd.as(AMQ::Protocol::Table)
xd["queue"] == q_name &&
xd["reason"] == "rejected"
end
x_death_q_dlx_rejected = x_death_q_dlx_rejected.as?(AMQ::Protocol::Table).should_not be_nil
x_death_q_dlx_rejected["count"].should eq 10

x_death_q_dlx2_expired = x_death.find do |xd|
xd = xd.as(AMQ::Protocol::Table)
xd["queue"] == "#{q_name}2" &&
xd["reason"] == "expired"
end
x_death_q_dlx2_expired = x_death_q_dlx2_expired.as?(AMQ::Protocol::Table).should_not be_nil
x_death_q_dlx2_expired["count"].should eq 10
end
end
end
Loading