1
votes

I'm using WildFly AS and running my EJB application with standalone-full configuration. I've created message-driven bean, but for some reason, it doesn't receive messages.

@MessageDriven(name = "receiver",
    activationConfig = {
            @ActivationConfigProperty(
                    propertyName = "destinationType",
                    propertyValue = "javax.jms.Topic"
            ),
            @ActivationConfigProperty(
                    propertyName = "destination",
                    propertyValue = "Ecare"
            ),
            @ActivationConfigProperty(
                    propertyName = "acknowledgeMode",
                    propertyValue = "Auto-acknowledge"
            )})
@ResourceAdapter("activemq-ra.rar")
public class JMSListener implements MessageListener {
    private Logger logger = Logger.getLogger("JMSListener logger");
    private JMSNotifier jmsNotifier = new JMSNotifier();

@Override
public void onMessage(Message message) {
    logger.info("Message received");
    jmsNotifier.notifyAllSubscribers();
}
}

I've tried to send messages from an application and manually via ActiveMQ console. I can see them coming, but MDB never reads anything. My only guess that it might be actually listening to messages from some JMS system embedded into the server, while I'm sending them to independent ActiveMQ system, but I don't know how to check it.

ADDITION: Basically, there are all configurations I've found in standalone-full.xml that are connected to JMS.

<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
        <server name="default">
            <security-setting name="#">
                <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
            </security-setting>
            <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
            <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
            <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
                <param name="batch-delay" value="50"/>
            </http-connector>
            <in-vm-connector name="in-vm" server-id="0">
                <param name="buffer-pooling" value="false"/>
            </in-vm-connector>
            <http-acceptor name="http-acceptor" http-listener="default"/>
            <http-acceptor name="http-acceptor-throughput" http-listener="default">
                <param name="batch-delay" value="50"/>
                <param name="direct-deliver" value="false"/>
            </http-acceptor>
            <in-vm-acceptor name="in-vm" server-id="0">
                <param name="buffer-pooling" value="false"/>
            </in-vm-acceptor>
            <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
            <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
            <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
            <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
            <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
        </server>
    </subsystem>

and in <subsystem xmlns="urn:jboss:domain:ejb3:5.0">

        <mdb>
            <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
            <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
        </mdb>

I was trying to add the following configuration

<subsystem xmlns="urn:jboss:domain:resource-adapters:2.0">
    <resource-adapters>
        <resource-adapter id="activemq">
            <archive>
                activemq-rar-5.10.0.rar
            </archive>

            <transaction-support>XATransaction</transaction-support>

            <config-property name="UseInboundSession">
                false
            </config-property>

            <config-property name="Password">
                defaultPassword
            </config-property>

            <config-property name="UserName">
                defaultUser
            </config-property>

            <config-property name="ServerUrl">
                tcp://localhost:61616
            </config-property>

            <connection-definitions>
                <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ConnectionFactory" enabled="true" pool-name="ConnectionFactory">

                    <xa-pool>
                        <min-pool-size>1</min-pool-size>
                        <max-pool-size>20</max-pool-size>
                        <prefill>false</prefill>
                        <is-same-rm-override>false</is-same-rm-override>
                    </xa-pool>

                </connection-definition>
            </connection-definitions>

            <admin-objects>
                <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/activemq/queue/TestQueue" use-java-context="true" pool-name="TestQueue">

                    <config-property name="PhysicalName">
                        activemq/queue/TestQueue
                    </config-property>

                </admin-object>

                <admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:jboss/activemq/topic/TestTopic" use-java-context="true" pool-name="TestTopic">

                    <config-property name="PhysicalName">
                        activemq/topic/TestTopic
                    </config-property>

                </admin-object>
            </admin-objects>
        </resource-adapter>
    </resource-adapters>
</subsystem>

I also put this resource in mdb tag, but deployemt was failing because some componets already existed. After that, I tried to delete default activemq configuration, but that time deployment failed because it was missing some components.

1
Can you paste the configuration for the ActiveMQ JCA resource adapter from your server configuration file? Also, does the console indicate that there are any consumers connected to the queue?Justin Bertram
@JustinBertram in the console I only see how many messages were queued, and there's always 0 consumers and 0 dequeued messages. Looks like my guess was correct and I was trying to receive messages from embedded ActiveMQ while sending them to standalone one. But now I have problems with server's configuration. I've updated my topic, could you check it, please?Никита Михайлов
How are you sending your messages? Can you include details about your producer's client library and configuration? I don't see how your MDB could be connecting to the embedded instance of ActiveMQ Artemis running within Wildfly as it has no listeners on port 61616 and also has no support for OpenWire by default.Justin Bertram
@JustinBertram I've added activemq-client dependency in my pom.xml file and I'm sending my messages just like here activemq.apache.org/hello-world.html. The only difference is that instead of using "vm://localhost" i use ActiveMQConnection.DEFAULT_BROKER_URL which is localhost:61616 I believe. It has no other configurations and it works, I do think that it's consumer's problem.Никита Михайлов

1 Answers

0
votes

So, I spent a lot of time trying to make it work, got tilted, stopped trying for a few days, then followed these https://blog.coffeebeans.at/archives/230 instructions without touching standalone-full.xml and everything worked!