,但是有一些关于未关闭的JMS连接的警告,然后由ActiveMQ关闭。 MDB得到一个messageHandler注入,它获得注入了replysender的方法在下面给出。MessageDrivenBean:AMQ122000:我正在关闭一个JMS连接,当您通过MDB发送某些消息时,您仍然打开
这是我得到的警告:当试块已完成下面的代码中
[org.apache.activemq.artemis.jms.client] (Finalizer) AMQ122000: I''m closing a JMS connection you left open. Please make sure you close all JMS connections explicitly before letting them go out of scope! see stacktrace to find out where it was created: java.lang.Exception
at org.apache.activemq.artemis.jms.client.ActiveMQConnection.<init>(ActiveMQConnection.java:155)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:750)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:233)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:229)
[...]
警告时(不是每个时间)(如此直接log.debug后(..)) :
private Message doSendAndReturn(XmlMessageCreator messageCreator) throws JMSException {
Message message = null;
try (Session session = cf.createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);) {
MessageProducer producer = session.createProducer(jmsReplyQueue);
message = messageCreator.createMessage(session);
producer.send(message);
log.debug("JMSTemplate sended message to myEnvironment with ID "
+ message.getJMSMessageID()
+ "\n Using Thread "
+ Thread.currentThread().getName());
}
return message;
}
我仍然读取即使世界的连接工厂但“CF”无参考是经由上下文中定义的全局单变量这些警告也发生:
@Resource(lookup = "java:/myProject_myEnvironment_factory")
private ConnectionFactory cf;
当在log.debug(...)上设置一个断点时,我可以看到它似乎工作了一段时间,但有时却不行。这种方法在前三次工作时被调用约7次,然后一次抛出警告四次(可能也是前一次调用),等等。 每次我在webapp中执行特定的任务时,这都是可重复的。
我不知道这里出了什么问题。
任何意见将不胜感激。提前致谢。