Я хотел бы отследить, какие клиенты создают, какие температуры, чтобы я мог отправлять сообщения конкретным клиентам.
Код: Выделить всё
activemq.management
...
< /code>
my-кодовый фрагмент: < /p>
ServerLocator locator = ActiveMQClient.createServerLocator("vm://0");
locator.setMinLargeMessageSize(6291456);
ClientSessionFactory clientSessionFactory = locator.createSessionFactory();
session_ = clientSessionFactory.createSession(false, true);
ClientConsumer notificationConsumer = session_.createConsumer("activemq.management");
notificationConsumer.setMessageHandler(new MessageHandler() {
@Override
public void onMessage(ClientMessage clientMessage) {
log_.info(">>> Received notification:");
}
});
< /code>
my python client: < /p>
#!venv/bin/python3
import time
import stomp
import json
import uuid
class MyListener(stomp.ConnectionListener):
def on_error(self, frame):
print(f"received an error {frame.body}")
def on_heartbeat(self):
print('on heartbeat')
def on_disconnected(self):
print('on disconnect')
def on_message(self, frame):
print(f"received a message: {frame.body}")
#print(f"received a message: {frame}")
myuuid = uuid.uuid4()
print(f"myuuid = {myuuid}")
conn = stomp.Connection12([('127.0.0.1', 61616)], heartbeats=(5000,5000))
#conn.set_listener('', stomp.PrintingListener())
conn.set_listener('', MyListener())
conn.connect(None, None, wait=True)
print("subscribing...")
conn.subscribe(destination=f"/temp-queue/{myuuid}", id=3, ack='auto')
print("sleeping...")
time.sleep(60)
Подробнее здесь: https://stackoverflow.com/questions/795 ... n-consumer