I am quite new to the world of JMS and Artemis and I’m struggling to make use of the management API to send a JMS message to my stand alone broker.
I am on Artemis 2.38
I want to update the address settings without using the broker.xml but I keep just getting null as a reply and the settings clearly don’t change when I go to test them.
I Followed along with a similar post here and was able to come up with this bit of code. here
try (JMSContext context = activeMQConnectionFactory.createContext(JMSContext.AUTO_ACKNOWLEDGE)) {
//You MUST explicitly create this queue for management operations.
Queue managementQueue = context.createQueue("activemq.management");
Message message = context.createMessage();
JMSManagementHelper.putOperationInvocation(
message,
ResourceNames.BROKER, // Targetted Resource
"addAddressSettings", // Operation to invoke
"ri.trips1", // Address match
null, // Dead letter address (DLA)
null, // Expiry address
-1L, // Expiry delay
true, // Last value queue
7, // Max delivery attempts
-1L, // Max size bytes
0, // Page size bytes
-1, // Page max cache size
1000L, // Redelivery delay
1.0, // Redelivery multiplier
-1L, // Max redelivery delay
-1L, // Slow consumer threshold
false, // Slow consumer policy
null, // Slow consumer notification interval
-1L, // Min large message size
-1L, // Consumer window size
null, // Auto-create queues
true, // Auto-create addresses
false, // Auto-delete queues
false, // Auto-delete addresses
true // Auto-delete created queues
);
context.createProducer().send(managementQueue, message);
Message response = context.createConsumer(managementQueue).receive(5000);
if (response != null && JMSManagementHelper.hasOperationSucceeded(response)) {
System.out.println("Address settings applied successfully.");
} else {
System.err.println("Failed to apply address settings");
}
} catch (JMSException e) {
e.printStackTrace();
}
The code block here is always resolving to failed because the response is always null. However it is creating the address “activemq.management” just fine.
I am on Artemis 2.38
Any help on this would greatly appreciated!
Sergio Scaramuzzi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.