Java 未找到Wildfly 15外部Artemis ActiveMQ目标
我有一个带有外部ActiveMQ的wildfly 15,并使用一个资源适配器。但我无法连接到要写入的队列 但我可以在排队的时候听 以下是我的配置: ironjacamar.xml:Java 未找到Wildfly 15外部Artemis ActiveMQ目标,java,jakarta-ee,wildfly,activemq-artemis,Java,Jakarta Ee,Wildfly,Activemq Artemis,我有一个带有外部ActiveMQ的wildfly 15,并使用一个资源适配器。但我无法连接到要写入的队列 但我可以在排队的时候听 以下是我的配置: ironjacamar.xml: <admin-objects> <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/HELLOWORLDMD
<admin-objects>
<admin-object class-name="org.apache.activemq.command.ActiveMQQueue"
jndi-name="java:jboss/activemq/queue/HELLOWORLDMDBQueue1234">
<config-property name="PhysicalName">
activemq/queue/HELLOWORLDMDBQueue
</config-property>
</admin-object>
</admin-objects>
我的侦听器bean:
@ResourceAdapter("activemq.rar")
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "activemq/queue/HELLOWORLDMDBQueue") })
public class RemoteActiveMQConsumer implements MessageListener {
@Override
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
try {
final String text = ((TextMessage) msg).getText();
System.out.println(text);
} catch (final JMSException e) {
throw new RuntimeException(e);
}
} else {
System.out.println(msg);
}
}
}
bean的pom.xml包含:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.9.1</version>
<scope>provided</scope>
</dependency>
感谢您的帮助与类似,您似乎正试图使用ActiveMQ 5.x JCA资源适配器中的管理对象来配置JMS队列管理对象,但随后使用ActiveMQ Artemis客户端来处理该队列。ActiveMQ 5.x和ActiveMQ Artemis是完全不同的客户机/服务器实现。你不能那样把它们混在一起
您不需要配置任何与ActiveMQ 5.x JCA资源适配器相关的内容。只需在Wildfly的消息传递子系统中定义您的队列,并创建指向远程代理的连接工厂。我的Artemis ActiveMQ版本是Apache ActiveMQ Artemis 2.6.3地址在Artemis 1.5和2.6之间更改。默认情况下,Wildfly仍在使用旧前缀。重命名“远程”队列或在资源适配器上使用setEnable1xPrefixesfalse。如何在资源适配器中设置此选项?因为我只使用ra.xml:-D,重命名远程队列是什么意思?谢谢我尝试将队列重命名为jms.queue.activemq/queue/HELLOWORLDMDBQueue,但没有区别您可以在WF15中使用外部连接工厂和队列,而不使用内部代理在完整答案中对此进行解释。好的,但我使用activemq Artemis作为外部代理,我必须再次查看资源适配器。我很困惑,因为我可以从队列中读取:-我想象您可以从队列中读取,因为MDB使用的是ActiveMQ 5.x JCA RA,它通过ActiveMQ Artemis支持的OpenWire协议进行通信。但是,您仍然不能将一个客户端实现中的对象与另一个客户端实现中的对象混合。
@ResourceAdapter("activemq.rar")
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "activemq/queue/HELLOWORLDMDBQueue") })
public class RemoteActiveMQConsumer implements MessageListener {
@Override
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
try {
final String text = ((TextMessage) msg).getText();
System.out.println(text);
} catch (final JMSException e) {
throw new RuntimeException(e);
}
} else {
System.out.println(msg);
}
}
}
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.9.1</version>
<scope>provided</scope>
</dependency>
Caused by: javax.jms.InvalidDestinationException: Foreign destination:queue://activemq/queue/HELLOWORLDMDBQueue
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.checkDestination(ActiveMQMessageProducer.java:349)
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:217)
at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:206)
at org.apache.activemq.artemis.ra.ActiveMQRAMessageProducer.send(ActiveMQRAMessageProducer.java:142)
at org.apache.activemq.artemis.jms.client.ActiveMQJMSProducer.send(ActiveMQJMSProducer.java:98)