在多线程/多应用程序环境中使用 Oracle Streams AQ,我AQOracleSQLException
仅在一个线程中运行约 10 分钟后收到:Exhausted Resultsset。
oracle.AQ.AQOracleSQLException: Exhausted Resultset
at oracle.AQ.AQOracleSession.getQueue(AQOracleSession.java:751)
at au.com.xxx.queue.OracleQueue$$anonfun$2.apply(OracleQueue.scala:53)
通过AQOracleSession
Spring 汇集如下:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/MessageManagerDB"/>
</bean>
<bean id="aqSessionFactory" class="au.com.xxx.queue.AQSessionFactory">
<constructor-arg ref="dataSource"/>
</bean>
<bean id="aqSessionTarget" factory-bean="aqSessionFactory"
factory-method="createAQSession" scope="prototype"/>
<bean id="aqSessionPoolTargetSource"
class="org.springframework.aop.target.CommonsPoolTargetSource">
<property name="targetBeanName" value="aqSessionTarget"/>
<property name="maxSize" value="25"/>
</bean>
<bean id="aqSession" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource" ref="aqSessionPoolTargetSource"/>
</bean>
使用工厂方法createAQSession
(在 Scala 中):
def createAQSession = {
val wasConnection = dataSource.getConnection.asInstanceOf[WSJdbcConnection]
val connection = WSCallHelper.getNativeConnection(wasConnection).asInstanceOf[Connection]
SessionWithConnection(AQDriverManager.createAQSession(connection), connection)
// SessionWithConnection is just a case class akin to
// Tuple2[AQOracleSession, Connection]
}
异常是从 this 块的最后一行抛出的:
def sessionAndConnection = {
applicationContext.getBean("aqSession").asInstanceOf[SessionWithConnectionI]
}
def write(category: String, relatedId: Option[String], payload: String): Array[Byte] = {
val (session, conn) = {
val sc = sessionAndConnection
(sc.session, sc.connection)
}
val queueDef = dao.queueForWriting(category, relatedId).map{_.name}
val queue = queueDef.map{name => session.getQueue("QUSR", name)}
显然,我不是直接处理ResultSet
used within AQOracleSession
。
我正在使用与Connection
关联的Session
,但这直到稍后在相同的方法中,所以这里不能出错:
val clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION)
池配置是否可能不正确并且同一会话上有一些并发操作?其他日志中没有任何异常。