Connection
- class amqpstorm.Connection[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='ca_certificate.pem'), 'server_hostname': 'rmq.eandersson.net', 'check_hostname': True, 'verify_mode': ssl.CERT_REQUIRED, } 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 timeout
ssl (bool) – Enable SSL
ssl_options (dict) – SSL kwargs
client_properties (dict) – None or dict of client properties
poller (str) – Either “select” or “poll”. If you encounter file descriptor errors, consider switching to “poll”.
locale (str) – Locale used during connection negotiation. Defaults to “en_US”.
lazy (bool) – Lazy initialize the connection
- Raises:
AMQPConnectionError – Raises if the connection encountered an error.
- __init__(hostname: str, username: str, password: str, port: int = 5672, **kwargs: Any) None[source]
- property channels: dict[int, Channel]
Returns a dictionary of the Channels currently available.
- Return type:
- property is_blocked: bool
Is the connection currently being blocked from publishing by the remote server.
- Return type:
- property max_allowed_channels: int
Returns the maximum allowed channels for the connection.
- Return type:
- property max_frame_size: int
Returns the maximum allowed frame size for the connection.
- Return type:
- property socket: _socket.socket | None
Returns an instance of the Socket used by the Connection.
- Return type:
- channel(rpc_timeout: float = 60, lazy: bool = False) Channel[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() None[source]
Check Connection for errors.
- Raises:
AMQPConnectionError – Raises if the connection encountered an error.
- Returns:
- close() None[source]
Close the Connection.
- Raises:
AMQPConnectionError – Raises if the connection encountered an error.
- Returns:
- open() None[source]
Open Connection.
- Raises:
AMQPConnectionError – Raises if the connection encountered an error.
- classmethod __new__(*args, **kwargs)
UriConnection
- class amqpstorm.UriConnection[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='ca_certificate.pem'), 'server_hostname': 'rmq.eandersson.net' } connection = amqpstorm.UriConnection( 'amqps://guest:guest@rmq.eandersson.net:5671/%2F?heartbeat=60', ssl_options=ssl_options )
- Parameters:
- Raises:
TypeError – Raises on invalid uri.
ValueError – Raises on invalid uri.
AttributeError – Raises on invalid uri.
AMQPConnectionError – Raises if the connection encountered an error.