Chelsea Salyards created ARTEMIS-4339:
-----------------------------------------
Summary: Configure dead letter addresses through API
Key: ARTEMIS-4339
URL: https://issues.apache.org/jira/browse/ARTEMIS-4339
Project: ActiveMQ Artemis
Issue Type: Wish
Components: API
Environment: Artemis client is
org.apache.activemq:artemis-core-client:2.19.1, Java code is using the Artemis
Core API.
Artemis server appears to be 2.28.0, and is running in a Docker container.
Reporter: Chelsea Salyards
My project is working on an integration with ActiveMQ Artemis, and it has the
requirement to create queues and dead letter queues on the fly. When the queues
are created, we want to be able to dynamically set the queue to use dead letter
queues we just created and not just use the default dead letter address for the
server. I would like to be able to do this through the Java API and the Artemis
CLI.
[This
page|https://activemq.apache.org/components/artemis/documentation/latest/undelivered-messages.html]
documents how to set through the broker.xml, which will not work for our use
case. I have seen references on the internet that suggest at one point the API
allowed users to set dead letter addresses through the JMX API, but none of
that seems to exist anymore.
The closest I have been able to accomplish this is through the following code:
{code:java}
String queueName = ... // whatever the name of the custom queue is
String deadLetterChannelName = // whatever the name of the custom
dead letter address is
ActiveMQServerControl serverControl = ... // insert method to pull
ActiveMQServerControl object from JMX
String jsonAddressSettings =
serverControl.getAddressSettingsAsJSON(queueName);
AddressSettingsInfo defaultInfo =
AddressSettingsInfo.from(jsonAddressSettings);
serverControl.addAddressSettings(
queueName,
deadLetterChannelName,
deadLetterChannelName,
defaultInfo.getExpiryDelay(),
false,
defaultInfo.getMaxDeliveryAttempts(),
defaultInfo.getMaxSizeBytes(),
defaultInfo.getPageSizeBytes(),
defaultInfo.getPageCacheMaxSize(),
defaultInfo.getRedeliveryDelay(),
defaultInfo.getRedeliveryMultiplier(),
defaultInfo.getMaxRedeliveryDelay(),
defaultInfo.getRedistributionDelay(),
true,
defaultInfo.getAddressFullMessagePolicy(),
defaultInfo.getSlowConsumerThreshold(),
defaultInfo.getSlowConsumerCheckPeriod(),
defaultInfo.getSlowConsumerPolicy(),
false,
false,
false,
false
{code}
Looking at the Artemis console this appears to be setting my custom dead letter
address from the default, but I haven't figured out what happens if
addAddressSettings() gets called multiple times or if there is a way to remove
address settings later.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)