使用 ActiveMQ jmsActivationSpec 未触发的 Open Liberty JMS

Open Liberty JMS with ActiveMQ jmsActivationSpec not triggering

我正在尝试使用 activeMq 作为 JMS 的代理,具有开放的自由。我设法在队列中获取消息,但我的激活规范从未触发。我正在阅读日志中的以下内容。

[25/07/20 18:13:51:857 CEST] 00000330 com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime           I CNTR0180I: The FailedKalenderUpdateProcessor message-driven bean in the typedagkalender-backend.jar module of the typedagkalender-ear application is bound to the jms/typedagkalender/kalenderupdates/dlqueueAS activation specification.
[25/07/20 18:13:51:857 CEST] 00000330 com.ibm.ws.jca.cm.ConnectorService                           I J2CA8050I: An authentication alias should be used instead of defining a user name and password on jms/typedagkalender/kalenderupdates/dlqueueAS.
[25/07/20 18:13:51:858 CEST] 00000330 SystemOut                                                    O 2020-07-25 18:13:51,858 [utor-thread-692] INFO  ActiveMQEndpointWorker         - Starting
[25/07/20 18:13:51:858 CEST] 00000330 com.ibm.ws.jca.service.EndpointActivationService             I J2CA8801I: The message endpoint for activation specification jms/typedagkalender/kalenderupdates/dlqueueAS and message driven bean application typedagkalender-ear#typedagkalender-backend.jar#FailedKalenderUpdateProcessor is activated.
[25/07/20 18:13:51:858 CEST] 00000330 com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime           I CNTR0180I: The KalenderUpdateProcessor message-driven bean in the typedagkalender-backend.jar module of the typedagkalender-ear application is bound to the jms/typedagkalender/kalenderupdates/queueAS activation specification.
[25/07/20 18:13:51:858 CEST] 000002cb SystemOut                                                    O 2020-07-25 18:13:51,858 [utor-thread-591] INFO  ActiveMQEndpointWorker         - Establishing connection to broker [tcp://localhost:61616]
[25/07/20 18:13:51:858 CEST] 00000330 com.ibm.ws.jca.cm.ConnectorService                           I J2CA8050I: An authentication alias should be used instead of defining a user name and password on jms/typedagkalender/kalenderupdates/queueAS.
[25/07/20 18:13:51:860 CEST] 00000330 SystemOut                                                    O 2020-07-25 18:13:51,859 [utor-thread-692] INFO  ActiveMQEndpointWorker         - Starting
[25/07/20 18:13:51:860 CEST] 00000330 com.ibm.ws.jca.service.EndpointActivationService             I J2CA8801I: The message endpoint for activation specification jms/typedagkalender/kalenderupdates/queueAS and message driven bean application typedagkalender-ear#typedagkalender-backend.jar#KalenderUpdateProcessor is activated.
[25/07/20 18:13:51:860 CEST] 0000032b SystemOut                                                    O 2020-07-25 18:13:51,860 [utor-thread-687] INFO  ActiveMQEndpointWorker         - Establishing connection to broker [tcp://localhost:61616]
[25/07/20 18:13:51:870 CEST] 000002cb SystemOut                                                    O 2020-07-25 18:13:51,870 [utor-thread-591] INFO  ActiveMQEndpointWorker         - Successfully established connection to broker [tcp://localhost:61616]
[25/07/20 18:13:51:871 CEST] 0000032b SystemOut                                                    O 2020-07-25 18:13:51,870 [utor-thread-687] INFO  ActiveMQEndpointWorker         - Successfully established connection to broker [tcp://localhost:61616]

这是我的 server.xml 配置 jms 部分

<?xml version="1.0" encoding="UTF-8"?>
<server>
    <!-- JMS CONFIGURATION -->
    <resourceAdapter id="ActiveMQResourceAdapter" location="${server.config.dir}/resources/lib/resource-adapter/activemq-rar-5.16.0.rar">
      <properties.activemq ServerUrl="tcp://localhost:61616" />
    </resourceAdapter>

    <messagingEngine>
        <queue id="Typedagkalender_destination" />
        <queue id="_SYSTEM.Exception.Destination" />
    </messagingEngine>

    <jmsQueueConnectionFactory jndiName="jms/typedagkalender/kalenderupdates/queueCF" connectionManagerRef="ConMgr">
        <properties.ActiveMQResourceAdapter />
    </jmsQueueConnectionFactory> -->

    <connectionManager id="ConMgr" maxPoolSize="${jms.ConMgr.maxPoolSize}" />

    <jmsQueue id="jms/typedagkalender/kalenderupdates/queue" jndiName="jms/typedagkalender/kalenderupdates/queue">
        <properties.ActiveMQResourceAdapter PhysicalName="Typedagkalender_destination" />
    </jmsQueue>
    <jmsQueue id="jms/typedagkalender/kalenderupdates/dlqueue" jndiName="jms/typedagkalender/kalenderupdates/dlqueue">
        <properties.ActiveMQResourceAdapter PhysicalName="_SYSTEM.Exception.Destination" />
    </jmsQueue>

    <jmsActivationSpec id="jms/typedagkalender/kalenderupdates/queueAS">
        <properties.ActiveMQResourceAdapter destinationType="javax.jms.Queue" destination="jms/typedagkalender/kalenderupdates/queue" />
    </jmsActivationSpec>
    <jmsActivationSpec id="jms/typedagkalender/kalenderupdates/dlqueueAS">
        <properties.ActiveMQResourceAdapter destinationType="javax.jms.Queue" destination="jms/typedagkalender/kalenderupdates/dlqueue" />
    </jmsActivationSpec>
</server>

这是我应该激活的 bean

@TransactionAttribute(NOT_SUPPORTED)
@MessageDriven(mappedName = "jms/typedagkalender/kalenderupdates/queue", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/typedagkalender/kalenderupdates/queue")
})
public class KalenderUpdateProcessor implements MessageListener {

    private static final Logger LOGGER = LoggerFactory.getLogger(KalenderUpdateProcessor.class);

    @Inject
    private KalenderAbonnementService kalenderAbonnementService;

    @Override
    public void onMessage(Message message) {
        if (!(message instanceof TextMessage)) {
            LOGGER.error("Er is alleen ondersteuning voor TextMessages");
            return;
        }

        Auditor.setTimestamp(now());
        TextMessage textMessage = (TextMessage) message;

        try {
            LOGGER.debug("Textmessage gekregen voor KalenderJaargangVersieUpdate {}", textMessage.getText());
            handle(textMessage.getText());
        } catch (JMSException e) {
            LOGGER.error("Fout tijdens behandelen van message {}: {}", textMessage, e);
            throw new KalenderUpdateNotificationException("Fout tijdens behandelen van message " + textMessage, e);
        } finally {
            Auditor.destroy();
        }
    }
}

如果我使用 open liberty 提供的内部 JMS 实现,则此设置有效。但由于这只适用于单个节点,而且我需要一个持久的中央代理,所以我需要让它与 activeMQ 一起工作。我在此配置中缺少什么?

我找到了解决方案,似乎我不能为队列使用不同的物理名称,否则它将不起作用。好吧,解决方案在这里可能是一个大词,也许我不得不说我没有找到一种方法让它与不同的物理名称一起工作,而是通过使用相同的队列名称来实现的。

<?xml version="1.0" encoding="UTF-8"?>
<server>
    <!-- JMS CONFIGURATION -->
    <resourceAdapter id="ActiveMQResourceAdapter" location="${server.config.dir}/resources/lib/resource-adapter/activemq-rar-5.16.0.rar">
        <properties.activemq ServerUrl="tcp://localhost:61616" />
    </resourceAdapter>

    <messagingEngine>
        <queue id="jms/typedagkalender/kalenderupdates/queue" />
        <queue id="jms/typedagkalender/kalenderupdates/dlqueue" />
    </messagingEngine>

    <jmsQueueConnectionFactory jndiName="jms/typedagkalender/kalenderupdates/queueCF" connectionManagerRef="ConMgr">
        <properties.ActiveMQResourceAdapter />
    </jmsQueueConnectionFactory> -->

    <connectionManager id="ConMgr" maxPoolSize="${jms.ConMgr.maxPoolSize}" />

    <jmsQueue id="jms/typedagkalender/kalenderupdates/queue" jndiName="jms/typedagkalender/kalenderupdates/queue">
        <properties.ActiveMQResourceAdapter PhysicalName="jms/typedagkalender/kalenderupdates/queue" />
    </jmsQueue>
    <jmsQueue id="jms/typedagkalender/kalenderupdates/dlqueue" jndiName="jms/typedagkalender/kalenderupdates/dlqueue">
        <properties.ActiveMQResourceAdapter PhysicalName="jms/typedagkalender/kalenderupdates/dlqueue" />
    </jmsQueue>

    <jmsActivationSpec id="jms/typedagkalender/kalenderupdates/queueAS">
        <properties.ActiveMQResourceAdapter destinationType="javax.jms.Queue" destination="jms/typedagkalender/kalenderupdates/queue" />
    </jmsActivationSpec>
    <jmsActivationSpec id="jms/typedagkalender/kalenderupdates/dlqueueAS">
        <properties.ActiveMQResourceAdapter destinationType="javax.jms.Queue" destination="jms/typedagkalender/kalenderupdates/dlqueue" />
    </jmsActivationSpec>
</server>