or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

address-endpoints.mdasync-operations.mdauthentication.mdclient-apis.mdconnection-session.mderror-handling.mdhigh-level-messaging.mdindex.mdlow-level-protocol.mdmessage-management.mdtypes-constants.md
tile.json

tessl/pypi-uamqp

An AMQP 1.0 client library for Python

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/uamqp@1.6.x

To install, run

npx @tessl/cli install tessl/pypi-uamqp@1.6.0

index.mddocs/

uAMQP

An AMQP 1.0 client library for Python that provides comprehensive messaging capabilities for building applications using the Advanced Message Queuing Protocol. It offers both synchronous and asynchronous APIs for sending and receiving messages, supports various authentication methods, and provides extensive configuration options for connections, sessions, and message handling.

Package Information

  • Package Name: uamqp
  • Language: Python
  • Installation: pip install uamqp
  • Python Support: Python 3.6+

Core Imports

import uamqp

Common imports for basic messaging:

from uamqp import send_message, receive_message, receive_messages
from uamqp import Message, Source, Target
from uamqp import SendClient, ReceiveClient

Authentication imports:

from uamqp.authentication import SASLPlain, SASLAnonymous, SASTokenAuth

Basic Usage

import uamqp
from uamqp.authentication import SASLPlain

# Send a single message
target = "amqps://example.com/queue"
message = "Hello, AMQP!"
auth = SASLPlain("username", "password")

uamqp.send_message(target, message, auth=auth)

# Receive messages
source = "amqps://example.com/queue"
messages = uamqp.receive_messages(source, auth=auth, max_batch_size=10)

for message in messages:
    print(message.get_data())
    message.accept()

Architecture

The uAMQP library follows the AMQP 1.0 protocol architecture:

  • Connection: Manages the network connection to the AMQP broker
  • Session: Provides a logical grouping of links within a connection
  • Links: Unidirectional pathways for message transfer (MessageSender/MessageReceiver)
  • Message: The core unit of data transfer with properties, headers, and body
  • Authentication: Various authentication mechanisms (SASL, CBS tokens)

The library provides both high-level client APIs (SendClient, ReceiveClient) for ease of use and low-level protocol access for advanced scenarios.

Capabilities

High-Level Messaging API

Simple functions for common messaging operations including sending single messages, receiving single messages, and batch message operations.

def send_message(target, data, auth=None, debug=False):
    """Send a single message to AMQP endpoint."""

def receive_message(source, auth=None, timeout=0, debug=False):
    """Receive a single message from an AMQP endpoint."""

def receive_messages(source, auth=None, max_batch_size=None, timeout=0, debug=False, **kwargs):
    """Receive a batch of messages from an AMQP endpoint."""

def get_platform_info():
    """
    Get current platform information.
    
    Returns:
        str: Platform information string
    """

High-Level Messaging

Message Management

Core message classes for creating, manipulating, and processing AMQP messages including support for different body types, properties, and batch operations.

class Message:
    def __init__(self, body=None, properties=None, application_properties=None, 
                 annotations=None, header=None, msg_format=None, encoding='UTF-8', 
                 body_type=None, footer=None, delivery_annotations=None): ...

class BatchMessage:
    def __init__(self, data=None, properties=None, application_properties=None,
                 annotations=None, header=None, multi_messages=False, encoding='UTF-8'): ...

Message Management

Client APIs

High-level client classes for sending and receiving messages with built-in connection management, error handling, and batching capabilities.

class SendClient:
    def __init__(self, target, auth=None, client_name=None, debug=False, **kwargs): ...

class ReceiveClient:
    def __init__(self, source, auth=None, client_name=None, debug=False, **kwargs): ...

Client APIs

Authentication

Comprehensive authentication support including SASL mechanisms, token-based authentication, and Claims-Based Security (CBS) for Azure services.

class SASLPlain:
    def __init__(self, hostname, username, password, port=5671, **kwargs): ...

class SASTokenAuth:
    def __init__(self, hostname, port, token, token_type="servicebus.windows.net:sastoken", **kwargs): ...

Authentication

Connection and Session Management

Low-level AMQP protocol management including connection establishment, session management, and link creation for advanced messaging scenarios.

class Connection:
    def __init__(self, hostname, sasl=None, container_id=None, max_frame_size=None, **kwargs): ...

class Session:
    def __init__(self, connection, incoming_window=None, outgoing_window=None, handle_max=None): ...

Connection and Session Management

Address and Endpoints

AMQP endpoint addressing including source and target configuration with support for filters, dynamic addresses, and link properties.

class Source:
    def __init__(self, address=None, **kwargs): ...

class Target:
    def __init__(self, address=None, **kwargs): ...

Address and Endpoints

Low-Level Protocol Access

Direct access to AMQP protocol elements including message senders, receivers, and protocol-level message handling for advanced use cases.

class MessageSender:
    def __init__(self, session, source, target, name=None, **kwargs): ...

class MessageReceiver:
    def __init__(self, session, source, target, name=None, **kwargs): ...

Low-Level Protocol Access

AMQP Types and Constants

Type system for AMQP values and comprehensive constants for protocol states, error codes, and configuration options.

class AMQPType:
    def __init__(self, value): ...

class MessageState:
    WaitingToBeSent = 0
    WaitingForSendAck = 1
    SendComplete = 2
    # ...

AMQP Types and Constants

Error Handling

Comprehensive error handling with custom exceptions, error policies, and retry mechanisms for robust messaging applications.

class ErrorPolicy:
    def __init__(self, max_retries=3, on_error=None): ...

class AMQPError(Exception): ...
class AMQPConnectionError(AMQPError): ...

Error Handling

Async Operations

Asynchronous AMQP operations for Python 3.4+ with async/await support for high-performance messaging applications.

class SendClientAsync:
    def __init__(self, target, auth=None, client_name=None, debug=False, **kwargs): ...

class ReceiveClientAsync:
    def __init__(self, source, auth=None, client_name=None, debug=False, **kwargs): ...

Async Operations