【问题标题】:Wildfly 15 external Artemis ActiveMQ destination not found未找到 Wildfly 15 外部 Artemis ActiveMQ 目的地
【发布时间】:2019-05-18 14:54:27
【问题描述】:

我有一个带有外部 ActiveMQ 的 Wildfly 15 并使用资源适配器。但是我无法连接到要写入的队列。

但我可以在队列中听。

这是我的配置:

ironjacamar.xml:

<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>

ra.xml:

<adminobject>
    <adminobject-interface>javax.jms.Queue</adminobject-interface>
    <adminobject-class>org.apache.activemq.command.ActiveMQQueue</adminobject-class>
    <config-property>
        <config-property-name>PhysicalName</config-property-name>
        <config-property-type>java.lang.String</config-property-type>
    </config-property>
</adminobject>

Bean.java:

@Resource(lookup = "java:jboss/activemq/queue/HELLOWORLDMDBQueue1234")
private Queue queue;
@Inject
private JMSContext context;
someFunction(){
    context.createProducer().send(queue, "hier ist eine nachricht");
}

我的监听器 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);
        }
    }
}

用于 Beans 的 pom.xml 包含:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-client</artifactId>
    <version>5.9.1</version>
    <scope>provided</scope>
</dependency>

这与资源适配器中的 jar 版本相同。

HELLOWORLDMDBQueue 读取不是问题,但如果我尝试发送,我会得到以下输出:

错误:

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)

感谢您的帮助

【问题讨论】:

  • 我的 Artemis ActiveMQ 版本是Apache ActiveMQ Artemis 2.6.3
  • 地址在 Artemis 1.5 和 2.6 之间发生了变化。 Wildfly 默认仍使用旧前缀。重命名您的“远程”队列或在资源适配器上使用 setEnable1xPrefixes(false)。
  • 我如何在我的资源适配器中设置它?因为我只使用 ra.xml :-D,以及重命名远程队列是什么意思?谢谢!
  • 我尝试将队列重命名为jms.queue.activemq/queue/HELLOWORLDMDBQueue,但没有区别

标签: java jakarta-ee wildfly activemq-artemis


【解决方案1】:

类似于your other question on this subject,您似乎正在尝试使用 ActiveMQ 5.x JCA 资源适配器中的管理对象来配置 JMS 队列管理对象,但随后您正在使用 ActiveMQ Artemis 客户端工作与那个队列。 ActiveMQ 5.x 和 ActiveMQ Artemis 是完全不同的客户端/服务器实现。你不能这样混合它们。

您不需要配置与 ActiveMQ 5.x JCA 资源适配器相关的任何内容。只需在 Wildfly 的 messaging 子系统中定义您的队列并创建指向远程代理的连接工厂。

【讨论】:

  • 您可以在WF15中使用外部连接工厂和队列(没有内部代理)
  • 在完整的答案中得到解释会很棒。
  • 好的,但是我使用activemq Artemis作为外部代理,我必须再看一下资源适配器。我很困惑,因为我可以从队列中读取:-D
  • 我想你可以从队列中读取数据,因为 MDB 使用的是 ActiveMQ 5.x JCA RA,它通过 ActiveMQ Artemis 支持的 OpenWire 协议进行通信。但是,您仍然不能将来自一个客户端实现的 对象 与另一个混合。
猜你喜欢
  • 2019-04-29
  • 2023-04-02
  • 2016-11-18
  • 2019-11-14
  • 2017-03-13
  • 1970-01-01
  • 1970-01-01
  • 2017-01-03
  • 2016-06-23
相关资源
最近更新 更多