title: How to create a JMS listener for websphere MQ in WildFly 10.1.0?
body: <p>I have an application that's work as a jms listener running in WildFly 10.1.0. I have configured the resource adapter following this <a href="https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/Deploy_the_WebSphere_MQ_Resource_Adapter.html" rel="nofollow noreferrer">red hat reference</a>.</p>
  
  <p>The application is deployed without errors and everything looks like ok, but the listener don't get any message from the queue. Randomly sometimes some messages is readed from the queue. The same code runs without any problem in tomcat.</p>
  
  <p>Here are my resource adapter:</p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:resource-adapters:4.0"&gt;
  &lt;resource-adapters&gt;
      &lt;resource-adapter id="wmq"&gt;
          &lt;archive&gt;
              wmq.jmsra.rar
          &lt;/archive&gt;
          &lt;transaction-support&gt;NoTransaction&lt;/transaction-support&gt;
          &lt;connection-definitions&gt;
              &lt;connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/jms/jmsConnectionFactory" enabled="true" use-java-context="true" pool-name="jmsConnectionFactory"&gt;
                  &lt;config-property name="channel"&gt;
                      SYSTEM.DEF.SVRCONN
                  &lt;/config-property&gt;
                  &lt;config-property name="hostName"&gt;
                      172.16.41.76
                  &lt;/config-property&gt;
                  &lt;config-property name="transportType"&gt;
                      CLIENT
                  &lt;/config-property&gt;
                  &lt;config-property name="queueManager"&gt;
                      QM.DEV.01
                  &lt;/config-property&gt;
                  &lt;config-property name="port"&gt;
                      1415
                  &lt;/config-property&gt;
                  &lt;security&gt;
                      &lt;application/&gt;
                  &lt;/security&gt;
              &lt;/connection-definition&gt;
          &lt;/connection-definitions&gt;
          &lt;admin-objects&gt;
              &lt;admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/QUEUE.TEST.IN" pool-name="QUEUE.TEST.IN"&gt;
                  &lt;config-property name="baseQueueName"&gt;
                      QUEUE.TEST.IN
                  &lt;/config-property&gt;
                  &lt;config-property name="baseQueueManagerName"&gt;
                      QM.DEV.01
                  &lt;/config-property&gt;
              &lt;/admin-object&gt;
              &lt;admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/QUEUE.TEST.OUT" pool-name="QUEUE.TEST.OUT"&gt;
                  &lt;config-property name="baseQueueName"&gt;
                      QUEUE.TEST.OUT
                  &lt;/config-property&gt;
                  &lt;config-property name="baseQueueManagerName"&gt;
                      QM.DEV.01
                  &lt;/config-property&gt;
              &lt;/admin-object&gt;
          &lt;/admin-objects&gt;
      &lt;/resource-adapter&gt;
  &lt;/resource-adapters&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is how my connection factory is retrieved:</p>
  
  <pre><code>@Bean(name = "jmsConnectionFactory")
  public ConnectionFactory connectionFactory() throws NamingException {
      Context ctx = new InitialContext();
      ConnectionFactory jmsConnectionFactory = (ConnectionFactory) ctx.lookup("java:jboss/jms/jmsConnectionFactory");
  
      LoggerUtils.logDebug(this.getClass(), "Looking up jms connection factory reference: '{}' -&gt; '{}'", getAppConfigJms().getConnectionFactoryName(), jmsConnectionFactory);
      return jmsConnectionFactory;
  }
  </code></pre>
  
  <p>Here is how my queues are retrieved:</p>
  
  <pre><code>public Queue queueLookup(String queueName) throws NamingException, JMSException {
      Context ctx = new InitialContext();
      Queue queue = (Queue) ctx.lookup(queueName);
  
      LoggerUtils.logDebug(this.getClass(), "Looking up jms queue: '{}' -&gt; '{}'", queueName, queue.getQueueName());
      return queue;
  }
  </code></pre>
  
  <p>Here is how my listener is created:</p>
  
  <pre><code>public DefaultMessageListenerContainer configureListener(ConnectionFactory connectionFactory,
      Queue destinationQueue, MessageListener messageListener) throws JMSException {
  
      LoggerUtils.logDebug(this.getClass(), "Starting jms listener '{}' for queue: '{}'", messageListener, (destinationQueue != null ? destinationQueue.getQueueName() : null));
  
      DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
      listenerContainer.setConnectionFactory(connectionFactory);
      listenerContainer.setDestinationName(destinationQueue.getQueueName());
      listenerContainer.setMessageListener(messageListener);
      listenerContainer.setConcurrentConsumers(getAppConfigJms().getConcurrentConsumers().intValue());
      listenerContainer.setMaxConcurrentConsumers(getAppConfigJms().getMaxConcurrentConsumers().intValue());
      return listenerContainer;
  }
  </code></pre>
  
  <p>Has anyone had the same problem before?
  How can I do a test in my connection factory inside WildFly? </p>