ActiveMQ API Client
An auxiliary Python client for the ActiveMQ REST API, designed to facilitate administrative and monitoring tasks, rather than replacing the native messaging protocols (STOMP, MQTT) for sending and receiving messages.
Overview
ActiveMQ is a powerful open-source message broker that supports various messaging protocols like AMQP, MQTT, OpenWire, and WebSocket. While these protocols are recommended for regular message processing due to their efficiency, reliability, and feature set, there are certain administrative and monitoring tasks that can be efficiently handled using the ActiveMQ REST API. This Python client acts as a wrapper around the ActiveMQ REST API, providing developers and system administrators with a simple and convenient way to manage and monitor their ActiveMQ broker, queues, topics, and connections.
Features
This package is designed to assist with the following administrative and monitoring tasks:
- Broker Status: Check if the broker is running, its uptime, etc.
- Queue and Topic Monitoring: Monitor the number of messages enqueued, dequeued, and the number of consumers connected.
- Connection Management: Monitor the clients connected, their IP addresses, etc.
- Subscription Management: Monitor the clients subscribed to various topics.
Important Note
This package is not intended to replace the native messaging protocols (STOMP, MQTT, etc.) supported by ActiveMQ for sending and receiving messages. The REST API, and by extension this package, may not provide the same level of performance, scalability, reliability, and real-time updates as the native protocols. Therefore, it is recommended to use this package only for administrative and monitoring purposes, and to use the native messaging protocols for regular message processing in your application.
Installation
Install the package via pip:
pip install activemq-api-client
Usage
After installing the package, you can use it to interact with the ActiveMQ REST API.
from activemq_api_client.client import ActiveMQClient
# Create an ActiveMQClient instance
client = ActiveMQClient('http://localhost:8161', 'admin', 'admin')
# Get details about all queues
queues = client.get_queues_details()
print(queues)
# Get the number of consumers connected to a specific queue
consumer_count = client.get_queue_consumer_count('exampleQueue')
print(consumer_count)
# Close the connection to the broker
client.close()
Methods
The ActiveMQClient class provides the following methods to interact with the ActiveMQ REST API:
-
get_queues_details() -> List[dict]Returns a list of dictionaries containing details about all the queues. Each dictionary contains the following keys:
name: The name of the queue.consumerCount: The number of consumers connected to the queue.enqueueCount: The number of messages enqueued in the queue.dequeueCount: The number of messages dequeued from the queue.
-
get_queue_consumer_count(queue_name: str) -> Union[int, None]Returns the number of consumers connected to the specified queue, or
Noneif the queue does not exist. -
get_queue_enqueue_count(queue_name: str) -> Union[int, None]Returns the number of messages enqueued in the specified queue, or
Noneif the queue does not exist. -
get_queue_dequeue_count(queue_name: str) -> Union[int, None]Returns the number of messages dequeued from the specified queue, or
Noneif the queue does not exist. -
get_connections_details() -> List[dict]Returns a list of dictionaries containing details about all the connections. Each dictionary contains the following keys:
clientId: The client ID of the connection.remoteAddress: The remote address of the connection.
-
get_topics_details() -> List[dict]Returns a list of dictionaries containing details about all the topics. Each dictionary contains the following keys:
name: The name of the topic.consumerCount: The number of consumers connected to the topic.enqueueCount: The number of messages enqueued in the topic.
-
get_subscribers_details() -> List[dict]Returns a list of dictionaries containing details about all the subscribers. Each dictionary contains the following keys:
clientId: The client ID of the subscriber.subscriptionName: The subscription name of the subscriber.destinationName: The destination name of the subscriber.
-
close()Closes the connection to the ActiveMQ broker.
All methods except close send a GET request to the ActiveMQ REST API and return the response in the specified format. The close method does not send any request and simply closes the connection to the broker.
Closes the connection to the ActiveMQ broker.
License
This package is released under the MIT License. See the LICENSE file for more details.
Metadata
Release files for activemq-api-client 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| activemq-api-client-0.0.4.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| activemq_api_client-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / activemq-api-client-0.0.4.tar.gz
| Download URL | activemq-api-client-0.0.4.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
881dfca85a872fd2e6b19f46abc07196d55b73b56c1ec510c64df5398b03afc7
|
|
BLAKE2b-256 checksum How to use checksums |
c279e089efd9b75630edb19c51f5b08d8a98d4d134e5fcdd8676e32a67a65e2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.17
|
Release files / activemq_api_client-0.0.4-py3-none-any.whl
| Download URL | activemq_api_client-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a32f2e7772b6f5d95146fc718a04cda40a9923725241271b9866c529d15ee404
|
|
BLAKE2b-256 checksum How to use checksums |
34c448f75d2f4d878a5f3865de685777aa4c391879fec8a471fb24b47748cc3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.17
|