Method: AMQP.connect
- Defined in:
- lib/amqp.rb
.connect(connection_string, options = {}) ⇒ AMQP::Session .connect(connection_options) ⇒ AMQP::Session
This method assumes that EventMachine even loop is already running. If it is not the case or you are not sure, we recommend you use start instead. It takes exactly the same parameters.
Connects to AMQP broker and yields connection object to the block as soon as connection is considered open.
Handling authentication failures
AMQP 0.9.1 specification dictates that broker closes TCP connection when it detects that authentication has failed. However, broker does exactly the same thing when other connection-level exception occurs so there is no way to guarantee that connection was closed because of authentication failure.
Because of that, AMQP gem follows Java client example and hints at possibility of authentication failure. To handle it, pass a callable object (a proc, a lambda, an instance of a class that responds to #call) with :on_possible_authentication_failure option.
232 233 234 |
# File 'lib/amqp.rb', line 232 def self.connect( = ENV['RABBITMQ_URL'], = {}, &block) AMQP::Session.connect(, , &block) end |