
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
An AMQP 1.0 client library for Python.
This repo is no longer in active maintenance and we plan on deprecating it sometime in the first quarter of 2025. The EventHubs & Service Bus client libraries are now using the python based AMQP library which is under active development. If there is interest in using the new python library as standalone, please share your interest in this issue.
uAMQP for Python requires Python 3.6+ starting from v1.5, and Python 2.7 is no longer supported. If Python 2.7 is required, please install uAMQP v1.4.3:
$ pip install uamqp==1.4.3
Wheels are provided for most major operating systems, so you can install directly with pip:
$ pip install uamqp
If you are running a Linux distro that does not support ManyLinux1 or you need to customize the build based on your system settings and packages, you can install from source:
$ apt-get update
$ apt-get install -y build-essential libssl-dev uuid-dev cmake libcurl4-openssl-dev pkg-config python3-dev python3-pip $ pip3 install uamqp --no-binary :all:
If you are running Alpine, you can install from source:
$ apk add --update python3 py-pip python3-dev cmake gcc g++ openssl-dev build-base $ pip3 install uamqp --no-binary :all:
If you are running Red Hat, you can install from source:
$ yum install cmake gcc gcc-c++ make openssl-devel python3-devel $ pip3 install uamqp --no-binary :all:
Reference documentation can be found here: docs.microsoft.com/python/api/uamqp/uamqp.
In order to run the code directly, the Cython extension will need to be build first.
$ brew install cmake
This project has two C library dependencies. They are vendored in this repository in these versions:
To build, start by creating a virtual environment and installing the required Python packages:
$ python -m venv env
$ env/Scripts/activate
(env)$ pip install -r dev_requirements.txt
Next, run the build command:
$ python setup.py build_ext --inplace
The tests can be run from within the virtual environment. The extension must be built first using the instructions above.
(env)$ pytest
If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This version and all future versions will require Python 3.7+, Python 3.6 is no longer supported.
This version and all future versions will require Python 3.7+, Python 2.7 and Python 3.6 are no longer supported.
This version and all future versions will require Python 2.7 or Python 3.6+, Python 3.5 is no longer supported.
This version will be the last version to officially support Python 3.5, future versions will require Python 2.7 or Python 3.6+.
Added support for AMQP Sequence as the body type of an amqp message.
Added new class [uamqp.MessageBodyType]{.title-ref} to represent the body type of an amqp message, including:
- `Data`: The body consists of one or more data sections and each section contains opaque binary data. > - `Sequence`: The body consists of one or more sequence sections and each section contains an arbitrary number of structured data elements. > - `Value`: The body consists of one amqp-value section and the section contains a single AMQP value.
- [body_type]{.title-ref} which takes [uamqp.MessageBodyType]{.title-ref} to specify the body type of an amqp message.
- [footer]{.title-ref} which takes a dict to set the footer of an amqp message.
- [delivery_annotations]{.title-ref} which takes a dict to set the delivery annotations of an amqp message.
Added support for pickling [uamqp.Message]{.title-ref}.
Fixed bug that sending message of large size triggering segmentation fault when the underlying socket connection is lost.
Fixed bug in link flow control where link credit and delivery count should be calculated based on per message instead of per transfer frame.
- Where ever a [TimeoutError]{.title-ref} is raised in Python 3.x, this will be replaced with a new ~uamqp.errors.ClientTimeout exception in Python 2.7.
- A Python 2 [str]{.title-ref} object will be treated as [bytes]{.title-ref} in Python 3 and a Python 2 [unicode]{.title-ref} object will be treated like a Python 3 [str]{.title-ref}.
- Added uamqp.compat module for handling Py 2 vs 3 imports and types (PR#46, Thanks to maxkrivich).
AMQP encoding of an integer type will now automatically failover into a Long type or a double type if the value is too large.
Improved support for promptly detecting invalid ATTACH handles and raising the appropriate error.
Added types for AMQPDescribed, AMQPInt and AMQPuInt for explicit handling of int and unsigned int encoding.
Added new error [errors.AMQPClientShutdown]{.title-ref} as a wrapper for [KeyboardInterrupt]{.title-ref} to better handle interrupt handling.
Added better handling of keyboard interrupts during C callbacks to better facilitate clean client shutdown.
Added additional handling of keyboard interrupt at the C level to clean up annoying warnings.
Added classmethod [Message.decode_from_bytes]{.title-ref} to create a message from AMQP wire-encoded data.
Added [Message.encode_message]{.title-ref} method to retrieve the AMQP wire-encoded byte representation of the current message.
Fixed behaviour of [Message.get_message_encoded_size()]{.title-ref} to return accurate size.
Added new optional [callback]{.title-ref} argument to [client.mgmt_request]{.title-ref} to allow for custom handling of different status codes.
Added new client methods [auth_complete()]{.title-ref} and [client_ready()]{.title-ref} to allow for more fine-tuned monitoring or the client opening stages.
Client message handler is now a public attribute [client.message_handler]{.title-ref} ([SendClient._message_sender]{.title-ref} and [ReceiveClient._message_receiver]{.title-ref} are now deprecated).
Added automatic encoding of [datetime.datetime]{.title-ref} objects into AMQP timestamp.
Better support for Source filters with optional [descriptor]{.title-ref} argument in [Source.set_filter()]{.title-ref} and new [Source.get_filter()]{.title-ref} method.
Fixed Session settings not being passed to CBS session.
Added support for a callback on receipt on a Link ATTACH frame. Can be supplied to a client through the [on_attach]{.title-ref} keyword argument.
Removed unsued message.SequenceBody class.
Exposed BatchMessage.size_offset property for batch size customization.
API settled.
Behaviour change When a SendClient or SendClientAsync is shutdown, any remaining pending messages (that is messages in the states [WaitingToBeSent]{.title-ref} and [WaitingForSendAck]{.title-ref}) will no longer be cleared, but can be retrieved from a new attribute [SendClient.pending_messages]{.title-ref} in order to be re-processed as needed.
Behaviour change The function [SendClient.queue_message]{.title-ref} now allows for queueing multiple messages at once by simply passing in additional message instances:
- [send_client.queue_message(my_message)]{.title-ref}
- [send_client.queue_message(message_1, message_2, message_3)]{.title-ref}
- [send_client.queue_message(*my_message_list)]{.title-ref}
An authentication object will now raise a [ValueError]{.title-ref} if one attempts to use it for more than one connection.
Renamed internal [_async]{.title-ref} module to non-private [async_ops]{.title-ref} to allow for docs generation.
Reformatted logging for better performance.
Added additional logging.
Breaking change [MessageSender.send_async]{.title-ref} has been renamed to [MessageSender.send]{.title-ref}, and [MessageSenderAsync.send_async]{.title-ref} is now a coroutine.
Breaking change Removed [detach_received]{.title-ref} callback argument from MessageSender, MessageReceiver, MessageSenderAsync, and MessageReceiverAsync in favour of new [error_policy]{.title-ref} argument.
Added ErrorPolicy class to determine how the client should respond to both generic AMQP errors and custom or vendor-specific errors. A default policy will be used, but a custom policy can be added to any client by using a new [error_policy]{.title-ref} argument. Value must be either an instance or subclass of ErrorPolicy.
- The [error_policy]{.title-ref} argument has also been added to MessageSender, MessageReceiver, Connection, and their async counterparts to allow for handling of link DETACH and connection CLOSE events.
- The error policy passed to a SendClient determines the number of message send retry attempts. This replaces the previous [constants.MESSAGE_SEND_RETRIES]{.title-ref} value which is now deprecated.
- Added new ErrorAction object to determine how a client should > respond to an error. It has three properties: [retry]{.title-ref} (a boolean to determine whether the error is retryable), [backoff]{.title-ref} (an integer to determine how long the client should wait before retrying, default is 0) and [increment_retries]{.title-ref} (a boolean to determine whether the error should count against the maximum retry attempts, default is [True]{.title-ref}). Currently [backoff]{.title-ref} and [increment_retries]{.title-ref} are only considered for message send failures.
- Added [VendorConnectionClose]{.title-ref} and [VendorLinkDetach]{.title-ref} exceptions for non-standard (unrecognized) connection/link errors.
Added support for HTTP proxy configuration.
Added support for running async clients synchronously.
Added keep-alive support for connection - this is a background thread for a synchronous client, and a background async function for an async client. The keep-alive feature is disabled by default, to enable, set the [keep_alive_interval]{.title-ref} argument on the client to an integer representing the number of seconds between connection pings.
Added support for catching a Connection CLOSE event.
Added support for [Connection.sleep]{.title-ref} and [ConnectionAsync.sleep_async]{.title-ref} to pause the connection.
Added support for surfacing message disposition delivery-state (with error information).
Added [constants.ErrorCodes]{.title-ref} enum to map standard AMQP error conditions. This replaces the previous [constants.ERROR_CONNECTION_REDIRECT]{.title-ref} and [constants.ERROR_LINK_REDIRECT]{.title-ref} which are now both deprecated.
Added new super error [AMQPError]{.title-ref} from which all exceptions inherit.
Added new [MessageHandlerError]{.title-ref} exception, a subclass of [AMQPConnectionError]{.title-ref}, for Senders/Receivers that enter an indeterminate error state.
[MessageException]{.title-ref} is now a subclass of [MessageResponse]{.title-ref}.
Added [ClientMessageError]{.title-ref} exception, a subclass of [MessageException]{.title-ref} for send errors raised client-side.
Catching Link DETACH event will now work regardless of whether service returns delivery-state.
Fixed bug where received messages attempting to settle on a detached link crashed the client.
Fixed bug in amqp C DescribedValue.
Fixed bug where client crashed on deallocating failed management operation.
Breaking change Submodule [async]{.title-ref} has been renamed to the internal [_async]{.title-ref}. All asynchronous classes in the submodule can now be accessed from uamqp or uamqp.authentication directly.
Breaking change Anything returned by a callback supplied to receive messages will now be ignored.
Breaking change Changed message state enum values:
- [Complete -> SendComplete]{.title-ref}
- [Failed -> SendFailed]{.title-ref}
- [WaitingForAck -> WaitingForSendAck]{.title-ref}
- [ReceivedUnsettled]{.title-ref}
- [ReceivedSettled]{.title-ref}
- Combined the [AbandonMessage]{.title-ref} and [DeferMessage]{.title-ref} exceptions as [MessageModified]{.title-ref} to be in keeping with the AMQP specification.
- Renamed [AcceptMessage]{.title-ref} to [MessageAccepted]{.title-ref}.
- Renamed [RejectMessage]{.title-ref} to [MessageRejected]{.title-ref} which now takes [condition]{.title-ref} and [description]{.title-ref} arguments rather than [message]{.title-ref}.
Added [errors.LinkDetach]{.title-ref} exception as new subclass of [AMQPConnectionError]{.title-ref} as a wrapped for data in a Link DETACH dispostition.
Added [errors.LinkRedirect]{.title-ref} as a specific subclass of [LinkDetach]{.title-ref} to decode the specific redirect fields of a Link Redirect response.
Added [errors.MessageAlreadySettled]{.title-ref} exception for operations performed on a received message that has already returned a receipt dispostition.
Added [errors.MessageReleased]{.title-ref} exception.
Added [errors.ErrorResponse]{.title-ref} exception.
A received Message can now be explicitly settled through a set of new functions on the message:
- [Message.accept()]{.title-ref} > - [Message.reject(condition:str, description:str)]{.title-ref}
- [Message.release()]{.title-ref} > - [Message.modify(failed:bool, deliverable:bool, > annotations:dict)]{.title-ref}
- Received messages processed by callback ([ReceiveClient.receive_messages()]{.title-ref}) will be automatically "accepted" if no explicit response has been set on completion of the callback.
- Received messages processed by batch ([ReceiveClient.receive_message_batch()]{.title-ref}) will by automatically "accepted" before being returned to the user.
- Received messages processed by iterator ([ReceiveClient.receive_message_iter()]{.title-ref}) will by automatically "accepted" if no explicit response has been set once the generator is incremented.
- [uamqp.Connection.redirect(redirect_info, auth)]{.title-ref}
- [uamqp.async.ConnectionAsync.redirect_async(redirect_info, auth)]{.title-ref}
- [uamqp.SendClient.redirect(redirect_info, auth)]{.title-ref}
- [uamqp.ReceiveClient.redirect(redirect_info, auth)]{.title-ref}
- [uamqp.async.SendClientAsync.redirect_async(redirect_info, auth)]{.title-ref}
- [uamqp.async.ReceiveClientAsync.redirect_async(redirect_info, auth)]{.title-ref}
Added [on_detach_received]{.title-ref} argument to [Sender]{.title-ref} and [Receiver]{.title-ref} classes to pass in callback to run on Link DETACH.
Removed automatic char encoding for strings of length 1, and added [types.AMQPChar]{.title-ref} for explicit encoding.
Bumped uAMQP C version to 1.2.5
Bumped Azure C Shared Utility to 1.1.5
Fixed memory leaks in MessageProperties, MessageHeader and message annotations.
FAQs
AMQP 1.0 Client Library for Python
We found that uamqp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.