javajakarta-eeactivemq-classicwebsphere-libertymessage-driven-bean

Message-driven Beans in Open Liberty 19.0.0.3 do not activate when accessing ActiveMQ


I've got an OpenLiberty application server accessing Active MQ 5.15.18 via a Resource adapter, but I'm not able to properly configure the activation spec so the MDB is activated when a new message comes in.

The application is able to put messages in the output queue, however, the MDB is not activated when a new messages arrive in the input queue. The same code works on locally created queues over the embedded local provider (WLP as the JMS server, no ActiveMQ involved).

I've tried several code snippets cherry picked over stack overflow, my problem seems pretty much like WebSphere Liberty ActiveMQ but the same recipee is not working for me.

This is my MDB code:

@MessageDriven(name = "MyMDB",
        activationConfig = {  
           @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),  
           @ActivationConfigProperty(propertyName="destination", propertyValue="APP1_QIN"),  
           @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge")  
        })
public class MyMDB implements MessageListener {

    @PostConstruct
    public void postConstruct() {
        System.out.println("Init MDB");
    }

    @Override
    public void onMessage(Message message) {
        System.out.println("Message received in MDB: " + message);
    }

    @Resource
    MessageDrivenContext ejbcontext;
    @SuppressWarnings("unused")
    private void setMessageDrivenContext(EJBContext ejbcontext) {
    }

}

Below my server.xml:

<server description="defaultServer">
    <featureManager>
        <feature>webProfile-7.0</feature>
        <feature>localConnector-1.0</feature>
        <feature>wasJmsClient-2.0</feature>
        <feature>jca-1.7</feature>
    </featureManager>

    ...

    <resourceAdapter id="ActiveMQResourceAdapter" location="/path/to/libs/activemq-rar-5.15.8.rar">
        <properties.ActiveMQResourceAdapter ServerUrl="tcp://localhost:61616" />
    </resourceAdapter>

    <jmsQueueConnectionFactory connectionManagerRef="QueueConnMgr" jndiName="jms/QCF">  
        <properties.ActiveMQResourceAdapter />      
    </jmsQueueConnectionFactory>    

    <jmsQueue id="APP1_QIN" jndiName="jms/APP1_QIN">
        <properties.ActiveMQResourceAdapter PhysicalName="APP1_QIN" />
    </jmsQueue>

    <jmsQueue id="APP1_QOUT" jndiName="jms/APP1_QOUT">
        <properties.ActiveMQResourceAdapter PhysicalName="APP1_QOUT" />
    </jmsQueue>

     <jmsActivationSpec id="MyMDB">     
        <properties.ActiveMQResourceAdapter/> <!--  destination="APP1_QIN"   -->
    </jmsActivationSpec>

    <connectionManager id="QueueConnMgr" maxPoolSize="5"/>
</server>

I would expect the MDB to properly activate as soon as the messages come in, but it doesn't. Also, looking at the ActiveMQ console there seem to be zero consumers over this queue.

Any ideas?


Solution

  • Looks like your AS id might be incorrect, it should be in the following form: <activationSpec id="app1/module1/MyMessageDrivenBean"> with the correct name of the application, module and message driven bean.

    Check more details for configuring AS here Configuring JCA activation specifications