All Products
Search
Document Center

Simple Message Queue (formerly MNS):SMQ SDK for Python

Last Updated:Mar 11, 2026

Simple Message Queue (SMQ, formerly MNS) SDK for Python lets you manage queues, topics, and subscriptions programmatically.

Install the SDK

Install the latest version from PyPI:

pip install aliyun-mns-sdk

For source code and release history, see the aliyun-mns-python-sdk repository on GitHub.

Usage notes

  • The examples in this documentation use SMQ SDK for Python 1.2.0. For the full version history, see Versions.

  • For debugging, use the latest SDK version.

  • The Account, Queue, Topic, and Subscription classes are not thread-safe. Create a separate instance for each thread in multi-threaded applications.

Sample code

The SDK includes sample code for queue and topic operations.

Queue operations

Operation

Guide

Source code

Create a queue

Manage messages of a queue

create_queue.py

Delete a queue

Manage messages of a queue

delete_queue.py

Send a message

Manage messages of a queue

send_message.py

Receive and consume a message

Manage messages of a queue

recv_and_del_message.py

Topic operations

Operation

Guide

Source code

Create a topic

Send messages to a topic

create_topic.py

Create a subscription with a queue endpoint

Send messages to a topic

subscribe_queue_endpoint.py

Delete a topic

Send messages to a topic

delete_topic.py

Publish a message

Send messages to a topic

publish_message.py

What's next