Skip to content

Commit

Permalink
Federation links should use downstream queue name (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
spuun authored Nov 10, 2023
1 parent 1305a87 commit d555e72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions spec/upstream_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,22 @@ describe LavinMQ::Federation::Upstream do
upstream_q.bindings.size.should eq 0
end
end

describe "when @queue is nil" do
describe "#link(Queue)" do
it "should create link that consumes upstream queue with same name as downstream queue" do
vhost = Server.vhosts["/"]

vhost.declare_queue("q1", true, false)
vhost.declare_queue("q2", true, false)

upstream = LavinMQ::Federation::Upstream.new(vhost, "test", "amqp://", nil, nil)
link1 = upstream.link(vhost.queues["q1"])
link2 = upstream.link(vhost.queues["q2"])

link1.@upstream_q.should eq "q1"
link2.@upstream_q.should eq "q2"
end
end
end
end
2 changes: 1 addition & 1 deletion src/lavinmq/federation/upstream.cr
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module LavinMQ
end
upstream_q = @queue
if upstream_q.nil? || upstream_q.empty?
upstream_q = @queue = federated_q.name
upstream_q = federated_q.name
end
link = QueueLink.new(self, federated_q, upstream_q)
@q_links[federated_q.name] = link
Expand Down

0 comments on commit d555e72

Please sign in to comment.