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

Federation links should use downstream queue name #592

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
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
Loading