Parent

AMQP::Session

AMQP session represents connection to the broker. Session objects let you define callbacks for various TCP connection lifecycle events, for instance:

h2. Key methods

@api public

Attributes

server_properties[R]

Server properties (product information, platform, et cetera)

@return [Hash] @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)

server_capabilities[R]

Server capabilities (usually used to detect AMQP 0.9.1 extensions like basic.nack, publisher confirms and so on)

@return [Hash] @see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)

server_locales[R]

Locales server supports

@see bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)

Public Class Methods

authentication_failure_exception_class() click to toggle source

Overrides authentication failure exception to one that inherits from AMQP::Error and thus is backwards compatible.

@private @api plugin @return [Class] AMQP::PossibleAuthenticationFailureError

     # File lib/amqp/session.rb, line 297
297:     def self.authentication_failure_exception_class
298:       @authentication_failure_exception_class ||= AMQP::PossibleAuthenticationFailureError
299:     end
new(*args, &block) click to toggle source

@group Connecting, reconnecting, disconnecting

    # File lib/amqp/session.rb, line 39
39:     def initialize(*args, &block)
40:       super(*args, &block)
41: 
42:       @client_properties = {
43:         :platform    => ::RUBY_DESCRIPTION,
44:         :product     => "AMQP gem",
45:         :information => "http://github.com/ruby-amqp/amqp",
46:         :version     => AMQP::VERSION
47:       }
48:     end
tcp_connection_failure_exception_class() click to toggle source

Overrides TCP connection failure exception to one that inherits from AMQP::Error and thus is backwards compatible.

@private @api plugin @return [Class] AMQP::TCPConnectionFailed

     # File lib/amqp/session.rb, line 286
286:     def self.tcp_connection_failure_exception_class
287:       @tcp_connection_failure_exception_class ||= AMQP::TCPConnectionFailed
288:     end

Public Instance Methods

after_connection_interruption(&block) click to toggle source
after_recovery(&block) click to toggle source
Alias for: on_recovery
auto_recover() click to toggle source

Performs recovery of channels that are in the automatic recovery mode.

@see Channel#auto_recover @see Queue#auto_recover @see Exchange#auto_recover @api plugin

     # File lib/amqp/session.rb, line 268
268:     def auto_recover
269:       super
270:     end
auto_recovering?() click to toggle source

@return [Boolean] whether connection is in the automatic recovery mode @api public

     # File lib/amqp/session.rb, line 256
256:     def auto_recovering?
257:       super
258:     end
Also aliased as: auto_recovery?
auto_recovery?() click to toggle source
Alias for: auto_recovering?
before_recovery(&block) click to toggle source

Defines a callback that will be executed after TCP connection has recovered after a network failure but before AMQP connection is re-opened. Only one callback can be defined (the one defined last replaces previously added ones).

@api public

     # File lib/amqp/session.rb, line 239
239:     def before_recovery(&block)
240:       super(&block)
241:     end
broker() click to toggle source

@return [AMQP::Broker] Broker this connection is established with

     # File lib/amqp/session.rb, line 148
148:     def broker
149:       @broker ||= AMQP::Broker.new(@server_properties)
150:     end
broker_endpoint() click to toggle source

@return [String] Broker endpoint in the form of HOST:PORT/VHOST @api public

    # File lib/amqp/session.rb, line 71
71:     def broker_endpoint
72:       "#{self.hostname}:#{self.port}/#{self.vhost}"
73:     end
close(reply_code = 200, reply_text = "Goodbye", &block) click to toggle source
Alias for: disconnect
connected?() click to toggle source

@return [Boolean] true if this AMQP connection is currently open @api plugin

    # File lib/amqp/session.rb, line 52
52:     def connected?
53:       self.opened?
54:     end
disconnect(reply_code = 200, reply_text = "Goodbye", &block) click to toggle source

Properly close connection with AMQ broker, as described in section 2.2.4 of the {bit.ly/hw2ELX AMQP 0.9.1 specification}.

@api plugin @see #

     # File lib/amqp/session.rb, line 117
117:     def disconnect(reply_code = 200, reply_text = "Goodbye", &block)
118:       # defined here to make this method appear in YARD documentation. MK.
119:       super(reply_code, reply_text, &block)
120:     end
Also aliased as: close
handle_connection_interruption() click to toggle source

@private @api plugin

     # File lib/amqp/session.rb, line 219
219:     def handle_connection_interruption
220:       super
221:     end
host() click to toggle source
Alias for: hostname
hostname() click to toggle source

@return [String] Broker hostname this connection uses @api public

    # File lib/amqp/session.rb, line 58
58:     def hostname
59:       @settings[:host]
60:     end
Also aliased as: host
on_closed(&block) click to toggle source

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

@see # @api public

     # File lib/amqp/session.rb, line 175
175:     def on_closed(&block)
176:       # defined here to make this method appear in YARD documentation. MK.
177:       super(&block)
178:     end
on_connection_interruption(&block) click to toggle source

Defines a callback that will be executed after TCP connection is interrupted (typically because of a network failure). Only one callback can be defined (the one defined last replaces previously added ones).

@api public

     # File lib/amqp/session.rb, line 211
211:     def on_connection_interruption(&block)
212:       super(&block)
213:     end
on_error(&block) click to toggle source

Defines a callback that will be executed when connection is closed after connection-level exception. Only one callback can be defined (the one defined last replaces previously added ones).

@api public

     # File lib/amqp/session.rb, line 229
229:     def on_error(&block)
230:       super(&block)
231:     end
on_open(&block) click to toggle source

Defines a callback that will be executed when AMQP connection is considered open: after 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 # @api public

     # File lib/amqp/session.rb, line 162
162:     def on_open(&block)
163:       # defined here to make this method appear in YARD documentation. MK.
164:       super(&block)
165:     end
on_possible_authentication_failure(&block) click to toggle source

Defines a callback that will be run when TCP connection is closed before authentication finishes. Usually this means authentication failure. You can define only one callback.

@api public

     # File lib/amqp/session.rb, line 202
202:     def on_possible_authentication_failure(&block)
203:       # defined here to make this method appear in YARD documentation. MK.
204:       super(&block)
205:     end
on_recovery(&block) click to toggle source

Defines a callback that will be executed after AMQP connection has recovered after a network failure.. Only one callback can be defined (the one defined last replaces previously added ones).

@api public

     # File lib/amqp/session.rb, line 248
248:     def on_recovery(&block)
249:       super(&block)
250:     end
Also aliased as: after_recovery
on_tcp_connection_failure(&block) click to toggle source

Defines a callback that will be run when initial TCP connection fails. You can define only one callback.

@api public

     # File lib/amqp/session.rb, line 184
184:     def on_tcp_connection_failure(&block)
185:       # defined here to make this method appear in YARD documentation. MK.
186:       super(&block)
187:     end
on_tcp_connection_loss(&block) click to toggle source

Defines a callback that will be run when initial TCP connection fails. You can define only one callback.

@api public

     # File lib/amqp/session.rb, line 193
193:     def on_tcp_connection_loss(&block)
194:       # defined here to make this method appear in YARD documentation. MK.
195:       super(&block)
196:     end
port() click to toggle source

@return [String] Broker port this connection uses @api public

    # File lib/amqp/session.rb, line 65
65:     def port
66:       @settings[:port]
67:     end
reconnect(force = false, period = 2) click to toggle source

Reconnect to the broker using current connection settings.

@param [Boolean] force Enforce immediate connection @param [Fixnum] period If given, reconnection will be delayed by this period, in seconds. @api public

    # File lib/amqp/session.rb, line 88
88:     def reconnect(force = false, period = 2)
89:       # we do this to make sure this method shows up in our documentation
90:       # this method is too important to leave out and YARD currently does not
91:       # support cross-referencing to dependencies. MK.
92:       super(force, period)
93:     end
reconnect_to(connection_string_or_options = {}, period = 2) click to toggle source

A version of # that allows connecting to different endpoints (hosts). @see # @api public

     # File lib/amqp/session.rb, line 98
 98:     def reconnect_to(connection_string_or_options = {}, period = 2)
 99:       opts = case connection_string_or_options
100:              when String then
101:                AMQP::Client.parse_connection_uri(connection_string_or_options)
102:              when Hash then
103:                connection_string_or_options
104:              else
105:                Hash.new
106:              end
107: 
108:       super(opts, period)
109:     end
user() click to toggle source
Alias for: username
username() click to toggle source

@return [String] Username used by this connection @api public

    # File lib/amqp/session.rb, line 77
77:     def username
78:       @settings[:user]
79:     end
Also aliased as: user

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.