jmsactivemq-classicjava-ee-8open-libertyjca

Open Liberty JMS with ActiveMQ jmsActivationSpec not triggering


I'm trying to use activeMq as a broker for JMS with open liberty. I managed to get messages on the queue but my activation spec is never triggering. I'm reading the following in the logs.

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

This is my server.xml configuration the jms part

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

This is my bean that should activate

@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();
        }
    }
}

This setup works if I use the internal JMS implementation that open liberty provides. But since that would only work for a single node and I need a persistent central broker, I need to get it to work with activeMQ. What am I missing in this configuration ?


Solution

  • I found the solution, seems I can't use a different physicalname for the queue or it won't work. Well solution is a big word here maybe, maybe I have to say I didn't find a way to make it work with a different physicalname but did by using the same queue name.

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