module AMQ::Settings
def self.configure(settings = nil)
-
(Hash)- Merged configuration parameters.
Options Hash:
(**settings)-
:broker(String) -- Broker name (use if you intend to use broker-specific features). -
:keyfile(String) -- Server private key file path. -
:certfile(String) -- Server certificate file path. -
:cacertfile(String) -- Certificate Authority (CA) certificate file path. -
:fail_if_no_peer_cert(Boolean) -- When set to true, TLS connection will be rejected if client fails to provide a certificate. -
:verify(Boolean) -- Controls peer verification mode. -
:auth_mechanism(Array) -- SASL authentication mechanisms to consider when negotiating a mechanism with the server. This parameter can be specified multiple times to specify multiple mechanisms, e.g. `?auth_mechanism=plain&auth_mechanism=amqplain`. -
:channel_max(Fixnum) -- Maximum number of channels to permit on this connection. -
:connection_timeout(Integer) -- Time in milliseconds to wait while establishing a TCP connection to the server before giving up. -
:heartbeat(Integer) -- Heartbeat timeout value in seconds to negotiate with the server. -
:frame_max(Fixnum) -- Maximum frame size to use. If broker cannot support frames this large, broker's maximum value will be used instead. -
:ssl(String) -- Should be use TLS (SSL) for connection? -
:pass(String) -- Password to use for authentication. -
:user(String) -- Username to use for authentication. -
:vhost(String) -- Virtual host to use. -
:port(String) -- Port AMQ broker listens on. -
:host(String) -- Hostname AMQ broker runs on.
Parameters:
-
Configuration(Hash) -- parameters to use.
def self.configure(settings = nil) case settings when Hash then if username = (settings.delete(:username) || settings.delete(:user)) settings[:user] ||= username end if password = (settings.delete(:password) || settings.delete(:pass)) settings[:pass] ||= password end self.default.merge(settings) when String then settings = self.parse_amqp_url(settings) self.default.merge(settings) when NilClass then self.default end end
def self.default
- See: AMQ::Client::Settings.configure -
def self.default @default ||= { # TCP/IP connection parameters host: "127.0.0.1", port: AMQ::Protocol::DEFAULT_PORT, auth_mechanism: [], # authentication parameters user: "guest", pass: "guest", vhost: "/", # client connection parameters frame_max: (128 * 1024), heartbeat: nil, connection_timeout: nil, channel_max: nil, # ssl parameters ssl: false, verify: false, fail_if_no_peer_cert: false, cacertfile: nil, certfile: nil, keyfile: nil } end
def self.parse_amqp_url(connection_string)
- Api: - public
Raises:
-
(ArgumentError)- When connection URI schema is not amqp or amqps, or the path contains multiple segments
Returns:
-
(Hash)- Connection parameters (:username, :password, :vhost, :host, :port, :ssl)
Parameters:
-
connection_string(String) -- AMQP connection URI, à la JDBC connection string. For example: amqp://bus.megacorp.internal:5877.
Other tags:
- Example: How vhost is parsed -
def self.parse_amqp_url(connection_string) AMQ::URI.parse(connection_string) end