如何通过核心更改 ActiveMQ Artemis 队列的路由类型 API
How change routing type of ActiveMQ Artemis queue via core API
我正在使用 ActiveMQ Artemis 2.17.0。我想通过 Java 客户端的核心 API 更改路由类型存在队列。我试过这个:
...
QueueSession session = createSession(connection)
Message message = session.createMessage();
final QueueConfiguration queueConfiguration = new org.apache.activemq.artemis.api.core.QueueConfiguration('testQueue');
queueConfiguration.setRoutingType(org.apache.activemq.artemis.api.core.RoutingType.MULTICAST);
queueConfiguration.setAddress('testQueue');
queueConfiguration.setAutoCreateAddress(true);
JMSManagementHelper.putOperationInvocation(message, 'testQueue', 'updateQueue', queueConfiguration.toJSON());
Message reply = requestor.request(message);
我收到此错误:
AMQ229069: no operation updateQueue/1
ClientSession
也有方法 createQueue
和 deleteQueue
但没有 updateQueue
。如何从客户端更改队列 API?
我找到了解决办法。首先,创建一个具有 2 种路由类型的地址,例如:
ClientSession session ...
...
session.createAddress(SimpleString.toSimpleString('testAddress'), EnumSet.allOf(RoutingType.class), false);
接下来,用这个地址创建队列:
final QueueConfiguration queueConfiguration = new QueueConfiguration('testQueue');
queueConfiguration.setRoutingType(RoutingType.ANYCAST);
queueConfiguration.setAddress('testAddress');
queueConfiguration.setAutoCreateAddress(false);
session.createQueue(queueConfiguration);
正是在这个队列可以改变路由类型
Queue managementQueue = session.createQueue(MANAGEMENT_QUEUE);
requestor = new QueueRequestor(session, managementQueue);
connection.start();
Message message = session.createMessage();
JMSManagementHelper.putOperationInvocation(message, 'broker', 'updateQueue', 'testQueue', 'MULTICAST', 2, false);
Message reply = requestor.request(message);
我正在使用 ActiveMQ Artemis 2.17.0。我想通过 Java 客户端的核心 API 更改路由类型存在队列。我试过这个:
...
QueueSession session = createSession(connection)
Message message = session.createMessage();
final QueueConfiguration queueConfiguration = new org.apache.activemq.artemis.api.core.QueueConfiguration('testQueue');
queueConfiguration.setRoutingType(org.apache.activemq.artemis.api.core.RoutingType.MULTICAST);
queueConfiguration.setAddress('testQueue');
queueConfiguration.setAutoCreateAddress(true);
JMSManagementHelper.putOperationInvocation(message, 'testQueue', 'updateQueue', queueConfiguration.toJSON());
Message reply = requestor.request(message);
我收到此错误:
AMQ229069: no operation updateQueue/1
ClientSession
也有方法 createQueue
和 deleteQueue
但没有 updateQueue
。如何从客户端更改队列 API?
我找到了解决办法。首先,创建一个具有 2 种路由类型的地址,例如:
ClientSession session ...
...
session.createAddress(SimpleString.toSimpleString('testAddress'), EnumSet.allOf(RoutingType.class), false);
接下来,用这个地址创建队列:
final QueueConfiguration queueConfiguration = new QueueConfiguration('testQueue');
queueConfiguration.setRoutingType(RoutingType.ANYCAST);
queueConfiguration.setAddress('testAddress');
queueConfiguration.setAutoCreateAddress(false);
session.createQueue(queueConfiguration);
正是在这个队列可以改变路由类型
Queue managementQueue = session.createQueue(MANAGEMENT_QUEUE);
requestor = new QueueRequestor(session, managementQueue);
connection.start();
Message message = session.createMessage();
JMSManagementHelper.putOperationInvocation(message, 'broker', 'updateQueue', 'testQueue', 'MULTICAST', 2, false);
Message reply = requestor.request(message);