Connection¶
-
class
amqpstorm.
Connection
(hostname, username, password, port=5672, **kwargs)[source]¶ 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.
-
channels
¶ Returns a dictionary of the Channels currently available.
Return type: dict
-
fileno
¶ Returns the Socket File number.
Return type: integer,None
-
is_blocked
¶ Is the connection currently being blocked from publishing by the remote server.
Return type: bool
-
max_allowed_channels
¶ Returns the maximum allowed channels for the connection.
Return type: int
-
max_frame_size
¶ Returns the maximum allowed frame size for the connection.
Return type: int
-
server_properties
¶ Returns the RabbitMQ Server Properties.
Return type: dict
-
socket
¶ Returns an instance of the Socket used by the Connection.
Return type: socket.socket
-
channel
(rpc_timeout=60, lazy=False)[source]¶ Open a Channel.
Parameters: rpc_timeout (int) – Timeout before we give up waiting for an RPC response from the server.
Raises: - AMQPInvalidArgument – Invalid Parameters
- AMQPChannelError – Raises if the channel encountered an error.
- AMQPConnectionError – Raises if the connection encountered an error.
Return type:
-
check_for_errors
()[source]¶ Check Connection for errors.
Raises: AMQPConnectionError – Raises if the connection encountered an error. Returns:
-
close
()[source]¶ Close the Connection.
Raises: AMQPConnectionError – Raises if the connection encountered an error. Returns:
-
open
()[source]¶ Open Connection.
Raises: AMQPConnectionError – Raises if the connection encountered an error.
UriConnection¶
-
class
amqpstorm.
UriConnection
(uri, ssl_options=None, client_properties=None, lazy=False)[source]¶ 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.