0
我有一個在WildFly 10.1.0中運行的jms監聽器。我已在此red hat reference之後配置了資源適配器。如何在WildFly 10.1.0中爲websphere MQ創建JMS偵聽器?
應用程序部署時沒有錯誤,一切看起來都沒事,但偵聽器沒有從隊列中獲取任何消息。隨機地有時會從隊列中獲取一些消息。在tomcat中運行相同的代碼沒有任何問題。
這裏是我的資源適配器:
<subsystem xmlns="urn:jboss:domain:resource-adapters:4.0">
<resource-adapters>
<resource-adapter id="wmq">
<archive>
wmq.jmsra.rar
</archive>
<transaction-support>NoTransaction</transaction-support>
<connection-definitions>
<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">
<config-property name="channel">
SYSTEM.DEF.SVRCONN
</config-property>
<config-property name="hostName">
172.16.41.76
</config-property>
<config-property name="transportType">
CLIENT
</config-property>
<config-property name="queueManager">
QM.DEV.01
</config-property>
<config-property name="port">
1415
</config-property>
<security>
<application/>
</security>
</connection-definition>
</connection-definitions>
<admin-objects>
<admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/QUEUE.TEST.IN" pool-name="QUEUE.TEST.IN">
<config-property name="baseQueueName">
QUEUE.TEST.IN
</config-property>
<config-property name="baseQueueManagerName">
QM.DEV.01
</config-property>
</admin-object>
<admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/QUEUE.TEST.OUT" pool-name="QUEUE.TEST.OUT">
<config-property name="baseQueueName">
QUEUE.TEST.OUT
</config-property>
<config-property name="baseQueueManagerName">
QM.DEV.01
</config-property>
</admin-object>
</admin-objects>
</resource-adapter>
</resource-adapters>
這裏是我的連接工廠是如何獲得:
@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: '{}' -> '{}'", getAppConfigJms().getConnectionFactoryName(), jmsConnectionFactory);
return jmsConnectionFactory;
}
這裏是我的隊列是如何獲得:
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: '{}' -> '{}'", queueName, queue.getQueueName());
return queue;
}
這裏是我的聽衆如何創建:
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;
}
有沒有人有過同樣的問題? 如何在WildFly內的連接工廠進行測試?