ActiveMQ-Artemis 2.6 使用JMS管理设置队列死信地址API

ActiveMQ-Artemis 2.6 Set queue dead letter address using JMS management API

我正在尝试通过 JMS 管理设置队列的死信地址 API。从阅读最新的 Artemis 文档看来,我应该能够使用 QueueControl.setDeadLetterAddress(...) 方法来做到这一点。请参阅 https://activemq.apache.org/artemis/docs/latest/management.html 并搜索 "setDeadLetterAddress"。

据我了解,这些方法的参数应该可以在此处的 Artemis QueueControl javadoc 中找到: https://activemq.apache.org/artemis/docs/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.html

但是,该文档没有提及 setDeadLetterAddress 方法或可能接受的参数。

QueueControl.setDeadLetterAddress 方法是否仍然存在,是否可以从 JMSManagementHelper.putOperationInvocation(...) 方法中调用它?

非常感谢!

查看名为 addAddressSettingsQueueControlImpl class code it is clear that the setDeadLetterAddress operation is no longer present. An operation in the ActiveMQServerControlImpl class 确实提供了为队列设置 DLA 的功能(以及许多其他设置)。

例如:

Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
Queue replyQueue = ActiveMQJMSClient.createQueue("management.reply");

JMSContext context = connectionFactory.createContext();
JMSConsumer consumer = context.createConsumer(replyQueue)) {
JMSProducer producer = context.createProducer();
producer.setJMSReplyTo(replyQueue);

// Using AddressSettings isn't required, but is provided
// for clarity.
AddressSettings settings = new AddressSettings()
        .setDeadLetterAddress(new SimpleString("my.messages.dla"))
        .setMaxDeliveryAttempts(5)
        .setExpiryAddress(new SimpleString("ExpiryAddress"))
        .setExpiryDelay(-1L) // No expiry
        .setLastValueQueue(false)
        .setMaxSizeBytes(-1) // No max
        .setPageSizeBytes(10485760)
        .setPageCacheMaxSize(5)
        .setRedeliveryDelay(500)
        .setRedeliveryMultiplier(1.5)
        .setMaxRedeliveryDelay(2000)
        .setRedistributionDelay(1000)
        .setSendToDLAOnNoRoute(true)
        .setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE)
        .setSlowConsumerThreshold(-1)  // No slow consumer checking
        .setSlowConsumerCheckPeriod(1000)
        .setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY)
        .setAutoCreateJmsQueues(true)
        .setAutoDeleteJmsQueues(false)
        .setAutoCreateJmsTopics(true)
        .setAutoDeleteJmsTopics(false)
        .setAutoCreateQueues(true)
        .setAutoDeleteQueues(false)
        .setAutoCreateAddresses(true)
        .setAutoDeleteAddresses(false);

Message m = context.createMessage();
JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "addAddressSettings",
        "my.messages", 
        settings.getDeadLetterAddress().toString(),
        settings.getExpiryAddress().toString(),
        settings.getExpiryDelay(),
        settings.isLastValueQueue(),
        settings.getMaxDeliveryAttempts(),
        settings.getMaxSizeBytes(),
        settings.getPageSizeBytes(),
        settings.getPageCacheMaxSize(),
        settings.getRedeliveryDelay(),
        settings.getRedeliveryMultiplier(),
        settings.getMaxRedeliveryDelay(),
        settings.getRedistributionDelay(),
        settings.isSendToDLAOnNoRoute(),
        settings.getAddressFullMessagePolicy().toString(),
        settings.getSlowConsumerThreshold(),
        settings.getSlowConsumerCheckPeriod(),
        settings.getSlowConsumerPolicy().toString(),
        settings.isAutoCreateJmsQueues(),
        settings.isAutoDeleteJmsQueues(),
        settings.isAutoCreateJmsTopics(),
        settings.isAutoDeleteJmsTopics(),
        settings.isAutoCreateQueues(),
        settings.isAutoDeleteQueues(),
        settings.isAutoCreateAddresses(),
        settings.isAutoDeleteAddresses());
producer.send(managementQueue, m);

Message response = consumer.receive();
// addAddressSettings returns void but this will also return errors if the
// method or parameters are wrong.
log.info("addAddressSettings Reply: {}", JMSManagementHelper.getResult(response));