我正在使用spring-integration从IBM MQ读取消息。由于消息量很大,因此我已经配置了 max-concurrent-consumers = 10 。消费者被撞坏,工作正常。
问题是当不再需要连接时,连接不会释放。
当所有10个使用者都在使用中时,从MQ Explorer,我可以看到10个线程已连接(打开输入计数)到队列。但是,当队列中没有消息时,线程(连接)的数量永远不会回到1。 MQ Explorer仍然显示10个连接到队列的线程。
这里有人遇到这样的事情并有解决方案吗?
感谢您的时间。
<jms:inbound-gateway id="mdmDemoInboundGateway"
request-destination="mdmDemoQueue"
error-channel="demoErrorChannel"
request-channel="mdmDemoChannel"
concurrent-consumers="1"
max-concurrent-consumers="10"
connection-factory="mdmJmsQueueConnectionFactory"/>
@Bean
public MQQueueConnectionFactory mdmMqQueueConnectionFactory(
@Value("${mq.mdm.host}") String host,
@Value("${mq.mdm.port}") String port,
@Value("${mq.mdm.channel}") String channel,
@Value("${mq.mdm.queue-manager}") String queueManager) {
MQQueueConnectionFactory mqConnectionFactory = new MQQueueConnectionFactory();
mqConnectionFactory.setHostName(host);
try {
mqConnectionFactory.setPort(Integer.parseInt(port));
mqConnectionFactory.setQueueManager(queueManager);
mqConnectionFactory.setChannel(channel);
mqConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
mqConnectionFactory.setCCSID(1208);
} catch (JMSException ex) {
log.error("Error creating MQQueueConnectionFactory ", ex);
}
return mqConnectionFactory;
}
@Bean
public UserCredentialsConnectionFactoryAdapter mdmJmsQueueConnectionFactory(
@Qualifier("mdmMqQueueConnectionFactory") ConnectionFactory mdmMqQueueConnectionFactory,
@Value("${mq.mdm.user}") String username,
@Value("${mq.mdm.password}") String password) {
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter();
userCredentialsConnectionFactoryAdapter.setUsername(username);
userCredentialsConnectionFactoryAdapter.setPassword(password);
userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(mdmMqQueueConnectionFactory);
return userCredentialsConnectionFactoryAdapter;
}