-
Notifications
You must be signed in to change notification settings - Fork 44
Allow MQTT/AMQP cross protocol binding #1216
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
base: main
Are you sure you want to change the base?
Conversation
Claude finished @kickster97's task —— View job Pull Request ReviewI've completed a comprehensive review of this PR that implements MQTT/AMQP cross-protocol binding functionality. Here are my findings and recommendations: Todo List
Overall AssessmentThis PR successfully implements cross-protocol binding between MQTT and AMQP, allowing AMQP queues/exchanges to bind to MQTT exchanges and vice versa. The implementation is architecturally sound but has several areas that need attention. Code Quality & Best Practices✅ Strengths:
|
6958bdd
to
b0dd5bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool feature! But allocations in the hot path is no good
2a74f01
to
5260eb4
Compare
4e808b7
to
46c14d6
Compare
I had some ideas that I wrote down in another PR: #1224 Mainly it was setting up Also one more suggestion, not use the WDYT? |
As we discussed, the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now understand why we setup @queues
and @exchanges
in the client, but I dont like it. It makes it really hard to understand and we are tying client together with exchanges.
I think we should find a better solution for this, even if it requires a bigger overhaul of the discovery strategy in exchanges. If we don't, I think it will get more and more difficult as the code grows with more features.
destination.publish(msg, false, queues, exchanges) | ||
msg.body_io.rewind | ||
end | ||
in LavinMQ::Exchange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between LavinMQ::Exchange
and LavinMQ::AMQP::Exchange
?
also count
here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is a wip now, found some bugs yesterday so needed to rewrite this. the difference is that LavinMQ::Exchange counts for both amqp and mqtt exchanges. but i need better code overall in this case section
if destination.publish(amqp_msg) | ||
count += 1 | ||
amqp_msg.body_io.rewind | ||
queues.add(destination) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These four lines are repeated three times, can we restructure to reduce repeating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, need to refactor this, just needed the case to work as expected for a while so we had a build that worked.
elsif source.name.empty? || destination.name.empty? | ||
access_refused(context, "Not allowed to bind to the default exchange") | ||
elsif destination.internal? | ||
elsif destination.internal? && destination.name != "mqtt.default" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is mqtt.default
an internal or default exchange? the if
above checks for default exchange and based on the name this is a default exchange.
Is there a way to not have the string "mqtt.default" here but rather some method on destination
to check wether we can bind/unbind to the change? Less hard coded strings is my goal here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i agree this is unclear. Its been a "good enough" solution up untill now. I think we should have it as a default exchange and let it behave more like an amq.topic exchange. @antondalgren lifts a good issue about bindings not persiting for mqtt exchange bound to amqp exchange/queues. this is because we onyl built it to support the mqtt use case.
tldr; we need to refactor the exchange's place in lavinmq :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but new features like this might be less prioritized next week/2 weeks to prioritize squashing bugs we found in 2.4.0
WHAT is this pull request doing?
Allow AMQP queues and exchanges bind to MQTT exchanges and session and vice versa.
Today the mqtt exchange is an internal exchange, we can consider to not have it this way
Note that AMQP queues will not receive retained messages on bind("subscribe"). But it will receive messages as usual when published.
Fixes #1136
HOW can this pull request be tested?
Run specs