Package: activemq-api-client
ActiveMQ API ClientAn 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.OverviewActiveMQ 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.FeaturesThis 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 NoteThis 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.InstallationInstall the package via pip:pip install activemq-api-clientUsageAfter installing the package, you can use it to interact with the ActiveMQ REST API.fromactivemq_api_client.clientimportActiveMQClient# Create an ActiveMQClient instanceclient=ActiveMQClient('http://localhost:8161','admin','admin')# Get details about all queuesqueues=client.get_queues_details()print(queues)# Get the number of consumers connected to a specific queueconsumer_count=client.get_queue_consumer_count('exampleQueue')print(consumer_count)# Close the connection to the brokerclient.close()MethodsTheActiveMQClientclass 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, orNoneif 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, orNoneif 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, orNoneif 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 exceptclosesend a GET request to the ActiveMQ REST API and return the response in the specified format. Theclosemethod does not send any request and simply closes the connection to the broker.Closes the connection to the ActiveMQ broker.LicenseThis package is released under the MIT License. See theLICENSEfile for more details.