Skip to content

Commit

Permalink
Fixup spec added in 1abcc51
Browse files Browse the repository at this point in the history
As pointed out in #137, if we don't block, we will close the connection
while consuming/ack:ing.

Close #137
  • Loading branch information
dentarg committed Nov 6, 2023
1 parent e73d99c commit 7215451
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/amqproxy_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,25 @@ describe AMQProxy::Server do
Fiber.yield

queue_name = "amqproxy-test-queue"
message_payload = "Message from AMQProxy specs"
num_received_messages = 0
num_messages_to_publish = 5

num_messages_to_publish.times do
AMQP::Client.start("amqp://localhost:5673") do |conn|
channel = conn.channel
queue = channel.queue(queue_name)
queue.publish_confirm("Message from AMQProxy specs")
queue.publish_confirm(message_payload)
end
sleep 0.1
end

AMQP::Client.start("amqp://localhost:5673") do |conn|
channel = conn.channel
channel.basic_consume(queue_name, tag: "AMQProxy specs") do |msg|
channel.basic_consume(queue_name, block: true, tag: "AMQProxy specs") do |msg|
body = msg.body_io.to_s
if body == "Message from AMQProxy specs"
# FIXME: ack:ing causes this bug
# https://github.com/cloudamqp/amqproxy/issues/137
# channel.basic_ack(msg.delivery_tag)
if body == message_payload
channel.basic_ack(msg.delivery_tag)
num_received_messages += 1
end
end
Expand Down

0 comments on commit 7215451

Please sign in to comment.