Connection

class amqpstorm.Connection(hostname, username, password, port=5672, **kwargs)

RabbitMQ Connection.

e.g.

import amqpstorm
connection = amqpstorm.Connection('localhost', 'guest', 'guest')

Using a SSL Context:

import ssl
import amqpstorm
ssl_options = {
    'context': ssl.create_default_context(cafile='cacert.pem'),
    'server_hostname': 'rmq.eandersson.net'
}
connection = amqpstorm.Connection(
    'rmq.eandersson.net', 'guest', 'guest', port=5671,
    ssl=True, ssl_options=ssl_options
)
Parameters
  • hostname (str) – Hostname

  • username (str) – Username

  • password (str) – Password

  • port (int) – Server port

  • virtual_host (str) – Virtual host

  • heartbeat (int) – RabbitMQ Heartbeat interval

  • timeout (int,float) – Socket timeout

  • ssl (bool) – Enable SSL

  • ssl_options (dict) – SSL kwargs

  • client_properties (dict) – None or dict of client properties

  • lazy (bool) – Lazy initialize the connection

Raises

AMQPConnectionError – Raises if the connection encountered an error.

property is_blocked

Is the connection currently being blocked from publishing by the remote server.

Return type

bool

property server_properties

Returns the RabbitMQ Server Properties.

Return type

dict

property socket

Returns an instance of the Socket used by the Connection.

Return type

socket.socket

property fileno

Returns the Socket File number.

Return type

integer,None

open()

Open Connection.

Raises

AMQPConnectionError – Raises if the connection encountered an error.

close()

Close the Connection.

Raises

AMQPConnectionError – Raises if the connection encountered an error.

Returns

channel(rpc_timeout=60, lazy=False)

Open a Channel.

Parameters

rpc_timeout (int) – Timeout before we give up waiting for an RPC response from the server.

Raises
Return type

amqpstorm.Channel

property channels

Returns a dictionary of the Channels currently available.

Return type

dict

check_for_errors()

Check Connection for errors.

Raises

AMQPConnectionError – Raises if the connection encountered an error.

Returns

property max_allowed_channels

Returns the maximum allowed channels for the connection.

Return type

int

property max_frame_size

Returns the maximum allowed frame size for the connection.

Return type

int

UriConnection

class amqpstorm.UriConnection(uri, ssl_options=None, client_properties=None, lazy=False)

RabbitMQ Connection that takes a Uri string.

e.g.

import amqpstorm
connection = amqpstorm.UriConnection(
    'amqp://guest:guest@localhost:5672/%2F?heartbeat=60'
)

Using a SSL Context:

import ssl
import amqpstorm
ssl_options = {
    'context': ssl.create_default_context(cafile='cacert.pem'),
    'server_hostname': 'rmq.eandersson.net'
}
connection = amqpstorm.UriConnection(
    'amqps://guest:guest@rmq.eandersson.net:5671/%2F?heartbeat=60',
    ssl_options=ssl_options
)
Parameters
  • uri (str) – AMQP Connection string

  • ssl_options (dict) – SSL kwargs

  • client_properties (dict) – None or dict of client properties

  • lazy (bool) – Lazy initialize the connection

Raises
  • TypeError – Raises on invalid uri.

  • ValueError – Raises on invalid uri.

  • AttributeError – Raises on invalid uri.

  • AMQPConnectionError – Raises if the connection encountered an error.