在我的应用程序中,我们已经配置了与weblogic 11g的jms连接,当JAVA应用程序读取消息时,我们看到连接在每次读取消息后打开和关闭 .
这是一个问题,因为应用程序正在阅读许多消息!以前有人有这个weblogic的问题吗?
对于这个问题,我们决定使用来自apache库的GenericObjectPool在我们的应用程序中创建一个连接池 .
在此之后我们赢得了30%的时间 . 所以我们为我们感到自豪 .
但很长一段时间后,我们发现“封闭连接”有错误
ERREUR 02004 : Impossible de créer une session JMS
at fr.edf.mpv2.commun.message.connection.AClientJMS.getQsession(AClientJMS.java:228)
at fr.edf.mpv2.commun.message.connection.AClientJMS.connect(AClientJMS.java:124)
at fr.edf.mpv2.commun.message.monitor.ReceiverThread.receive(ReceiverThread.java:159)
at fr.edf.mpv2.commun.message.monitor.ReceiverThread.run(ReceiverThread.java:66)
Caused by: oracle.jms.AQjmsException: Closed Connection
at oracle.jms.AQjmsSession.enableEventForMsgOrder(AQjmsSession.java:6550)
at oracle.jms.AQjmsSession.<init>(AQjmsSession.java:486)
at oracle.jms.AQjmsConnection.createQueueSession(AQjmsConnection.java:657)
at fr.edf.mpv2.commun.message.connection.AClientJMS.getQsession(AClientJMS.java:225)
... 3 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:3645)
at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:3606)
at oracle.jms.AQjmsSession.enableEventForMsgOrder(AQjmsSession.java:6541)
... 6 more
我不知道为什么我的连接关闭了 . weblogic可以在某个时候关闭连接并且池不刷新所以错误commin?我是否需要捕获此错误并尝试在getqueueSession之前创建另一个连接?
非常感谢,如果有人可以帮助我解决这个问题 . 我知道它不容易理解,但如果有人可以帮助:)
EDIT #1
这是weblogic中连接的xml配置:
<jdbc-connection-pool-params>
<initial-capacity>10</initial-capacity>
<max-capacity>30</max-capacity>
<shrink-frequency-seconds>0</shrink-frequency-seconds>
<connection-creation-retry-frequency-seconds>600</connection-creation-retry-frequency-seconds>
<test-frequency-seconds>0</test-frequency-seconds>
<test-connections-on-reserve>true</test-connections-on-reserve>
<test-table-name>SQL SELECT 1 FROM T_PARAM</test-table-name>
<statement-cache-size>10</statement-cache-size>
<statement-cache-type>LRU</statement-cache-type>
<seconds-to-trust-an-idle-pool-connection>0</seconds-to-trust-an-idle-pool-connection>
<statement-timeout>30</statement-timeout>
<pinned-to-thread>true</pinned-to-thread>
jndiname在weblogic.xml中配置
<resource-description>
<res-ref-name>jdbc/jmsQueuingDatasource</res-ref-name>
<jndi-name>jdbc/ctrnat_fco_jms</jndi-name>
</resource-description>
这是与 Spring 天的联系:
<bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean" singleton="true">
<property name="jndiName" value="java:comp/env/jdbc/jmsQueuingDatasource"/>
</bean>
我有一个获取数据源的spring bean:
DataSourceConnectionFactory包含getConnection和releaseconnection方法:
public JmsQueueConnection getConnection() throws TechniqueException {
LOGGER.debug("getConnection()");
LOGGER.debug("Création d'une connexion à la queue de message.");
JmsQueueConnection connection = new JmsQueueConnection(this.getDataSource());
LOGGER.debug("Connexion réussie");
return connection;
}
@Override
public void releaseConnection(JmsQueueConnection jmsQConn) throws TechniqueException {
try {
// on ferme simplement la connexion.
jmsQConn.close();
} catch (Exception e) {
throw new TechniqueException(e);
}
}
我的jms客户端在getSession之前执行此操作以获取getConnection:
protected JmsQueueConnection getConnection() throws TechniqueException, JMSException {
if (this.connection == null || this.connection.isClosed()) {
this.connection = getConnectionFactory().getConnection();
}
return this.connection;
}
如果你想要一些信息,我希望它可以提供帮助