in Domain mode : JMS submission to embedded activeMQ not working in JBoss EAP 7.0.0 release as documented

Version 2

    Likely a temporary bug (expect a comment to tell when/where fixed): but annoying bug, at least in this configuration: JBoss EAP 7.0.0. with embedded ActiveMQ ARTEMIS 1.1 started in Domain Mode (multiple servers)

     

    If you follow the documentation for submitting JMS messages to the inner Messaging provider, you will experience no exception messages, but no message is ever posted either.


    The online EAP 7 documentation "Confugring Messaging" - section 3.6 in particular - explains how to connect (here natively) to a local server "in VM". However the doc still references classes like "InVMConnectorFactory.class" which no longer exist in ARTEMIS but likely reference older HornetQ classes in EAP 6.

    You may indeed also check the original ARTEMIS 1.1 API javadoc for additional clues and even examples, which also do lack updates at the time of posting this blog.


    Most of us with a JMS expertise would indeed write the usual code, looking up a connection factory in JNDI, opening a Connection, a Session, setting the Queue, then creating a Producer and posting a message. The usual endeavor explained in every JMS tutorial, as well as in the ARTEMIS manual "Using JMS" at https://activemq.apache.org/artemis/docs/1.1.0/using-jms.html. The section entitled "The Code" provides a perfect example. The starting point is always the JNDI name of the JMS Connection Factory. All the JBoss and ActiveMQ/Artemis doc tell you to simply lookup for "ConnectionFactory" (a.k.a. "java:/ConnectionFactory") when dealing "in VM" - understand 'in the same JVM' - from your EJB's or servlet code.


    No message ever got submitted to the queues in this way, and no exception is thrown (except for instance if you provide a non existing queue name to post your messages). I found no log elsewhere telling about an error. Your message submission just vanishes and the target queue message counters stand still. This is really puzzling and I spent countless hours searching for a clue, else a stupid error in my code.

    You may be curious (although ridiculous because I was executing code in the same JVM)  to try the other documented connection factory, the remote connection factory, published in JNDI as "java:jboss/exported/jms/RemoteConnectionFactory", with the same effect: no error, but no message either.


    Actually, you shall turn to the "java:/JmsXA" Connection Factory also supplied in the 'Full' Domain profile for instance, created by default in fresh EAP installations.


    You may inject it in your beans:

        @Resource(name = "JmsXA")    // note that "java:/" must be omitted here

        private javax.jms.ConnectionFactory connectionFactory;


    Else perform an explicit lookup:

                javax.naming.InitialContext ctxt = new javax.naming.InitialContext();

                javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) ctxt.lookup("java:/JmsXA");

     

    If you miss it, you may add it to your domain.xml:

    ....

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">

            <server name="default">

                ...

                <in-vm-connector name="in-vm" server-id="0"/>

                <in-vm-acceptor name="in-vm" server-id="0"/>

                ...

                <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA  java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>

            </server>

     

    The only meaningful difference with "java:/ConnectionFactory" and "java:jboss/exported/jms/RemoteConnectionFactory" is that it is pooled... but it works.