-
Notifications
You must be signed in to change notification settings - Fork 137
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
When using the uri config option: Respect amqps specification and use default protocol ports if unspecified #305
Conversation
3cc2e48
to
e83bdc7
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.
Looks promising but can be improved further. Thank you!
lib/hutch/broker.rb
Outdated
@config[:mq_vhost] = u.path.sub(/^\//, "") | ||
@config[:mq_username] = u.user | ||
@config[:mq_password] = u.password | ||
end | ||
|
||
def default_mq_port | ||
@config[:mq_tls] ? 5671 : 5672 |
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.
Please switch to AMQ::Protocol::DEFAULT_PORT
and AMQ::Protocol::TLS_PORT
.
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.
Thanks @michaelklishin , ♻️
In ruby-amqp#159 functionality was added to hutch that meant that it would respect that when using `amqps://` as the URI scheme it would use TLS and also that when not specifying a port in the URI scheme it would default to the standard protocol ports (5671 for TLS connections, 5672 for non TLS connections). This functionality appears to have been lost since and is restored by this commit it also adds a new test case to prevent another regression.
e83bdc7
to
3ad4b31
Compare
Are failures in the JRuby build expected? Looking at the travis output all the specs passed but travis marked the build as a failure as it believed the build timed out: https://travis-ci.org/gocardless/hutch/jobs/329386746 |
With JRuby you have to properly close connections or the JVM won't ever terminate because RabbitMQ Java client will have an execution service with running non-daemon threads. So it's not related. |
What does this PR do?
Restores functionality implemented in #159 and since lost to:
amqps
specification when using the URI config option (ie. utilise TLS)This means that:
amqp://guest:guest@127.0.0.1/
connects to the server on port 5672 and does not utilise TLS.amqps://guest:guest@127.0.0.1/
connects to the server on port 5671 and does utilise TLS.It also adds test cases for this functionality to prevent another regression.
Where should the reviewer start?
Changes are all within
Hutch::Broker#parse_uri
Any background context you want to provide?
Background context can be found in the original issue ://github.com//issues/304
Any specific implementation details?
The test for covering when amqps scheme is utilised has to stub out
Hutch::Adapter
instead of acting like an integration test in a similar manner to the surrounding specs because it appears a default rabbitmq install does not activate TLS listeners and as such a user who was to run the test suite without changing their rabbitmq server config would get failing specs if the adapter was not stubbed.\cc @michaelklishin