gpt4 book ai didi

java - 从Java代码获取队列HornetQ列表

转载 作者:行者123 更新时间:2023-11-30 04:07:53 24 4
gpt4 key购买 nike

我尝试获取当前 Activity HornetQ 队列的列表,如下所示:

ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), getConfigMap()));
ClientSessionFactory factory = locator.createSessionFactory();

ClientSession session = return factory.createSession(true, true, 0);

ClientSession.BindingQuery result = session.bindingQuery(new SimpleString("localhost"));

System.out.println(result.getQueueNames().size());

但它返回0。看起来我执行了错误的 BindingQuery 但我在文档中没有找到任何示例。

最佳答案

回复有点晚了。希望它对某人有帮助。

ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
session.start();

ClientRequestor requestor = new ClientRequestor(session, "jms.queue.hornetq.management");
ClientMessage message = session.createMessage(false);
ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER, "queueNames");
ClientMessage reply = requestor.request(message);
Object queueNames = ManagementHelper.getResult(reply);

pom.xml:

    <dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-core-client</artifactId>
<version>2.3.0.CR1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-jms-client</artifactId>
<version>2.3.0.CR1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-server</artifactId>
<version>2.3.1.Final</version>
<scope>provided</scope>
</dependency>

关于java - 从Java代码获取队列HornetQ列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20315732/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com