0

在多线程/多应用程序环境中使用 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)

通过AQOracleSessionSpring 汇集如下:

<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)}

显然,我不是直接处理ResultSetused within AQOracleSession

正在使用与Connection关联的Session,但这直到稍后在相同的方法中,所以这里不能出错:

val clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION)

池配置是否可能不正确并且同一会话上有一些并发操作?其他日志中没有任何异常。

4

1 回答 1

0

这是我错误使用的 v10 驱动程序的缺陷。v11 RDBMS 驱动没有这个问题。

于 2011-04-14T13:35:19.460 回答