简体   繁体   中英

Mule JDBC update works intermittently

I need to constantly update a table in a loop and it works fine most of the times but once in a while Mule does update the table but it is not committed.

So, here is my flow. I poll a table where the flag is 0. Once it is polled, flag is set to 5. After calling a service, flag is set to 1. But if the service call fails, the flag is set back to 0 so that it'll be re-polled and processed.

If the service is down for few minutes, then this loop should keep going till the service is up. The below statement works mostly fine, but sometimes it doesn't update and the loop is broken.

Not sure whether it is Mule or DriverManager issue.

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

Flow:

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

I had a similar problem and the issue turned out to be an internal Mule exception. https://www.mulesoft.org/jira/browse/MULE-6889

I can't see the foreach loop in your flow. How are you looping? This exception is quite specific to for each loops. By restructuring the flow I could relatively easy sort it out (after weeks of troubleshooting)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM