by Anonymous » 25 Apr 2025, 09:07
Ich verwende eingebettete Activemq artemis 2.40.0.
Code: Select all
activemq.management
...
< /code>
Mein Code-Snippet: < /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>
Mein 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)
Ich hatte gehofft, eine Verwaltungsnachricht zu erhalten, wenn sich der Client verbindet und wenn er eine Temp-Queue erstellt, aber ich empfange keine Nachrichten in meinem MessageHandler Implementierung.>
Ich verwende eingebettete Activemq artemis 2.40.0.[code]activemq.management
...
< /code>
Mein Code-Snippet: < /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>
Mein 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)
[/code]
Ich hatte gehofft, eine Verwaltungsnachricht zu erhalten, wenn sich der Client verbindet und wenn er eine Temp-Queue erstellt, aber ich empfange keine Nachrichten in meinem MessageHandler Implementierung.>