Class AMQ::Client::Async::EventMachineClient
In: lib/amq/client/async/adapters/event_machine.rb
Parent: EM::Connection

Methods

Included Modules

AMQ::Client::Async::Adapter

Constants

Deferrable = EventMachine::DefaultDeferrable   Backwards compatibility with 0.7.0.a25. MK.

External Aliases

disconnect -> close
send_data -> send_raw

Public Class methods

Initiates connection to AMQP broker. If callback is given, runs it when (and if) AMQP connection succeeds.

@option settings [String] :host ("127.0.0.1") Hostname AMQ broker runs on. @option settings [String] :port (5672) Port AMQ broker listens on. @option settings [String] :vhost ("/") Virtual host to use. @option settings [String] :user ("guest") Username to use for authentication. @option settings [String] :pass ("guest") Password to use for authentication. @option settings [String] :ssl (false) Should be use TLS (SSL) for connection? @option settings [String] :timeout (nil) Connection timeout. @option settings [String] :logging (false) Turns logging on or off. @option settings [String] :broker (nil) Broker name (use if you intend to use broker-specific features). @option settings [Fixnum] :frame_max (131072) Maximum frame size to use. If broker cannot support frames this large, broker‘s maximum value will be used instead.

@param [Hash] settings

Public Instance methods

Whether we are in authentication state (after TCP connection was estabilished but before broker authenticated us).

@return [Boolean] @api public

Called by EventMachine reactor once TCP connection is successfully estabilished. @private

Called by AMQ::Client::Connection after we receive connection.open-ok. @api public

Called by AMQ::Client::Connection after we receive connection.close-ok.

@api public

For EventMachine adapter, this is a no-op. @api public

Called when time since last server heartbeat received is greater or equal to the heartbeat interval set via :heartbeat_interval option on connection.

@api plugin

Defines a callback that will be run when broker confirms connection termination (client receives connection.close-ok). You can define more than one callback.

@api public

on_connection(&block)

Alias for on_open

on_disconnection(&block)

Alias for on_closed

Defines a callback that will be executed when AMQP connection is considered open: client and broker has agreed on max channel identifier and maximum allowed frame size and authentication succeeds. You can define more than one callback.

@see on_possible_authentication_failure @api public

Periodically try to reconnect.

@param [Fixnum] period Period of time, in seconds, to wait before reconnection attempt. @param [Boolean] force If true, enforces immediate reconnection. @api public

EventMachine reactor callback. Is run when TCP connection is estabilished but before resumption of the network loop. Note that this includes cases when TCP connection has failed. @private

EventMachine receives data in chunks, sometimes those chunks are smaller than the size of AMQP frame. That‘s why you need to add some kind of buffer.

@private

Reconnect after a period of wait.

@param [Fixnum] period Period of time, in seconds, to wait before reconnection attempt. @param [Boolean] force If true, enforces immediate reconnection. @api public

Similar to reconnect, but uses different connection settings @see reconnect @api public

IS TCP connection estabilished and currently active? @return [Boolean] @api public

Called by EventMachine reactor when

  • We close TCP connection down
  • Our peer closes TCP connection down
  • There is a network connection issue
  • Initial TCP connection fails

@private

Protected Instance methods

[Validate]