【问题标题】:Mule JDBC update works intermittentlyMule JDBC 更新间歇性工作
【发布时间】:2014-10-09 13:10:55
【问题描述】:

我需要在循环中不断更新表,它在大多数情况下都可以正常工作,但有时 Mule 确实会更新表但未提交。

所以,这是我的流程。我轮询一个标志为 0 的表。一旦轮询,标志设置为 5。调用服务后,标志设置为 1。但如果服务调用失败,标志设置回 0 以便它将被重新轮询和处理。

如果服务关闭了几分钟,那么这个循环应该一直持续到服务启动。下面的语句大部分都可以正常工作,但有时它不会更新并且循环被破坏了。

不确定是 Mule 还是 DriverManager 的问题。

<jdbc-ee:outbound-endpoint queryTimeout="-1"  queryKey="updateEventReset" connector-ref="DatabaseEvents" exchange-pattern="one-way" doc:name="Database"/>

流程:

<mule>
<spring:bean id="jdbcEASDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
</spring:bean>
<jdbc-ee:connector dataSource-ref="jdbcEASDataSource" name="DatabaseEvents" transactionPerMessage="true" validateConnections="true" queryTimeout="-1" pollingFrequency="10000" doc:name="Database">
    <receiver-threading-profile maxThreadsActive="1"/>
    <jdbc-ee:query key="selectEvent" value="select * from EVENT_TEST where PROCESSED = 0 ORDER BY RowId" />
    <jdbc-ee:query key="selectEvent.ack" value="update EVENT_TEST set PROCESSED = 5 where RowId = #[map-payload:ROWID]" />
    <jdbc-ee:query key="updateEventProcessed" value="update EVENT_TEST set PROCESSED = 1 where RowId = #[flowVars['RowId']]" />
    <jdbc-ee:query key="updateEventReset" value="update EVENT_TEST set PROCESSED = 0 where PROCESSED = 5" />
</jdbc-ee:connector>
<flow name="EventLinkerDBPolling" doc:name="EventLinkerDBPolling" processingStrategy="synchronous">
    <jdbc-ee:inbound-endpoint queryKey="selectEvent" connector-ref="ISeriesDatabaseEvents" doc:name="ACSC Database"/>
    <vm:outbound-endpoint path="vm.toEventWSCall" exchange-pattern="one-way" doc:name="To Event Dining" />
</flow>
<flow name="EventWSProcessing" doc:name="EventWSProcessing" processingStrategy="synchronous">
      <vm:inbound-endpoint path="vm.toEventWSCall" exchange-pattern="one-way" doc:name="Event " >
        <vm:transaction action="NONE"/>
      </vm:inbound-endpoint>
      <set-variable variableName="RowId" value="#[map-payload:ROWID]" doc:name="Variable"/>
  <flow-ref name="ManagerClient" doc:name="Call  Flow Linker" />
      <jdbc-ee:outbound-endpoint queryKey="updateEventProcessed" connector-ref="DatabaseEvents" exchange-pattern="one-way" doc:name="Database"/>
  <catch-exception-strategy doc:name="Catch Exception Strategy">
    <choice doc:name="Choice">
        <when expression="#[ payload.getStatusCode() == 404 ]">
        <processor-chain>
            <jdbc-ee:outbound-endpoint queryTimeout="-1"  queryKey="updateEventReset" connector-ref="DatabaseEvents" exchange-pattern="one-way" doc:name="Database"/>
        </processor-chain>
        </when>
    </choice> 
  </catch-exception-strategy>
</flow>
</mule>

【问题讨论】:

  • 您在日志中看到任何异常或错误吗?
  • 不,我在日志中看到以下几行。它更新行但不提交。 com.mulesoft.mule.transport.jdbc.sql.command.executor.PreparedSqlCommandExecutor:命令执行成功:更新 EVENT_TEST 设置 PROCESSED = 0 其中 PROCESSED = 5 com.mulesoft.mule.transport.jdbc.sqlstrategy.UpdateSqlStatementStrategy:执行 SQL 语句: 0 行已更新

标签: jdbc driver mule esb


【解决方案1】:

我遇到了类似的问题,结果证明是 Mule 内部异常。 https://www.mulesoft.org/jira/browse/MULE-6889

我在您的流程中看不到 foreach 循环。你怎么循环? 这个异常对于每个循环都是非常特定的。通过重组流程,我可以相对容易地解决它(经过数周的故障排除)

【讨论】:

  • 感谢您对此进行调查。抱歉,由于格式不正确,我的问题没有完整的 ESB 流程,我现在修复了它。在流程中,我正在调用另一个 WebService,如果调用失败,我将“已处理”标志设置回 0,以便在下一次 DB 轮询中获取该 DB 行。这就是我制作循环的方式。
  • 我在第一次拍摄时也没有看到异常,异常可能在 Mule 流程中的其他地方。提交提交时不一定会抛出异常。
  • 顺便说一句:您发布的语句说:执行 SQL 语句:0 行已更新 - 从我的角度来看,这已经是提交消息。所以基本上更新只是没有效果。这似乎更像是您编写的 SQL 语句的问题。可能是一个错误的 where 参数....也很明显这可能是一个时间问题。当并行执行 WebService 调用时,它可能以不同的顺序接收调用然后发送它们。
猜你喜欢
  • 2017-06-13
  • 1970-01-01
  • 1970-01-01
  • 2014-06-03
  • 2019-11-22
  • 2015-12-02
  • 2020-06-12
  • 2012-08-08
  • 1970-01-01
相关资源
最近更新 更多