title: In Wildfly, MDB listening to external ActiveMQ gets a null JMSMessageId
body: <p>I am testing the connectivity of Wildfly16 / JBoss 7.2 with ActiveMQ Artemis 2.7. </p>
  
  <p>I have written a simple MDB, and it can consume messages from the remote ActiveMQ Artemis server. </p>
  
  <p>I get correctly the payload (text message) and the CorrelationId, but the received MessageId is null! This looks weird and is very annoying as I want to implement request/reply.</p>
  
  <ul>
  <li>To enable the access from Wildfly to the external ActiveMQ Artemis server, I followed the steps indicated in <a href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/configuring_messaging/resource_adapters#using_jboss_amq_for_remote_jms_communication" rel="nofollow noreferrer">31.3. Configuring the Artemis Resource Adapter to Connect to Red Hat JBoss AMQ 7</a>. It worked.</li>
  <li>I have created a simple Java client that is able to send/consume/browse the queues directly. When I consume a message with this client, I get the MessageId, the CorrelationId and all the stuff I expect.</li>
  <li>The issue appears with a Message Driven Bean on Wildfly 16, 17 and on JBoss 7.2 (I have tried each).</li>
  <li>The Jar of the MDB that I deploy on Wildfly has no dependency (6Kb)</li>
  </ul>
  
  <p>Below the code of the MDB</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Properties;
  import java.util.logging.Logger;
  
  import javax.ejb.ActivationConfigProperty;
  import javax.ejb.MessageDriven;
  
  import javax.jms.*;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  import org.jboss.ejb3.annotation.ResourceAdapter;
  
  @ResourceAdapter("activemq-ra-remote")
  @MessageDriven(name = "JmsTestMDB", activationConfig = {
          @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "testReqQueue"),
          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
  public class WildflyMdb implements MessageListener {
    private static final Logger LOGGER = Logger.getLogger(WildflyMdb.class.toString());
  
    public void onMessage(Message rcvMessage) {
      TextMessage txtMessage = null;
      try {
        if (rcvMessage instanceof TextMessage) {
      txtMessage = (TextMessage) rcvMessage;
         LOGGER.info("Received Message from queue: MessageId=" + rcvMessage.getJMSMessageID() + 
                     ", CorrelationId=" + rcvMessage.getJMSCorrelationID() +
                     ", Text='" + txtMessage.getText() + "'");
  
         LOGGER.info("rcvMessage (toString): " + rcvMessage.toString());
  
      } catch (Exception e) {
         LOGGER.severe("EXCEPTION:" + e.getMessage());
      }
   }
  
  </code></pre>
  
  <p>When I send following message with my Java client :</p>
  
  <ul>
  <li>MessageId: ID:DEVTEMP-PC-49242-1561392550500-1:1:1:1:1</li>
  <li>CorrelationId: CID:20190624180910</li>
  <li>Text Message: 'This is my test message'</li>
  </ul>
  
  <p>I get the following log from the MDB in Wildfly:</p>
  
  <pre><code>16:23:29,694 INFO  [class com.fluide.mdb.WildflyMdb] (Thread-360 (ActiveMQ-client-global-threads)) Received Message from queue: MessageId=null, CorrelationId=CID:20190624180910, Text='This is my test message'
  16:23:29,695 INFO  [class com.fluide.mdb.WildflyMdb] (Thread-360 (ActiveMQ-client-global-threads)) rcvMessage (toString): ActiveMQMessage[null]:PERSISTENT/ClientMessageImpl[messageID=946860, durable=true, address=testReqQueue,userID=null,properties=TypedProperties[__AMQ_CID=ID:DEVTEMP-PC-49242-1561392550500-0:1,_AMQ_GROUP_SEQUENCE=0,__HDR_BROKER_IN_TIME=1561392550749,_AMQ_ROUTING_TYPE=1,__HDR_ARRIVAL=0,__HDR_REPLY_TO=[0000 0011 6401 000D 7465 7374 5265 7370 5175 6575 65),__HDR_COMMAND_ID=5,JMSCorrelationID=CID:20190624180910,__HDR_PRODUCER_ID=[0000 0039 7B01 0025 4944 3A44 4556 5445 4D50 2D50 432D 3439 3234 322D 3135  ... 31 3339 3235 3530 3530 302D 313A 3100 0000 0000 0000 0100 0000 0000 0000 01),__HDR_MESSAGE_ID=[0000 004C 6E00 017B 0100 2549 443A 4445 5654 454D 502D 5043 2D34 3932 3432  ...  0000 0000 0001 0000 0000 0000 0001 0000 0000 0000 0001 0000 0000 0000 0000),__HDR_DROPPABLE=false]]
  </code></pre>
  
  <p>As you can see, the <code>MessageId</code> returns as <strong>null</strong> which doesn't look right.
  Any ideas?</p>