我有一个 Mule 流,我需要从数据库中获取行并写入文件。现在我在数据库中有 100 行,我需要一次从数据库中获取 5 行并写入文件,并在几次间隔后再次写入时间说 30 秒再获取 5 行并将有效负载写入文件.. 现在我的流程如下:-
<spring:beans>
<spring:bean id="DB_Source" name="DB_Source" class="org.enhydra.jdbc.standard.StandardDataSource">
<spring:property name="url" value="${url}"/>
<spring:property name="driverName" value="${driverName}"/>
</spring:bean>
</spring:beans>
<jdbc-ee:connector name="Database_Global" dataSource-ref="DB_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database" transactionPerMessage="true">
<!-- Here transactionPerMessage="false" so that it retrieve and display all the row at once-->
<jdbc-ee:query key="RetriveQuery" value="select * from getData"/> <!-- or we can use CALL sp_retrieveData(@Id=13) -->
</jdbc-ee:connector>
<context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/>
<flow name="InboundJDBC" doc:name="InboundJDBC" initialState="started">
<jdbc-ee:inbound-endpoint queryTimeout="-1" pollingFrequency="1000" doc:name="Database" connector-ref="Database_Global" queryKey="RetriveQuery">
<jdbc-ee:transaction action="ALWAYS_BEGIN" />
<!-- <property key="receiveMessageInTransaction" value="true"/> --><!-- This to receive all the row in once -->
</jdbc-ee:inbound-endpoint>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="5"/> <!-- Set the number of rows to be return at a time -->
<add-message-property key="MULE_CORRELATION_ID" value="1"/>
</message-properties-transformer>
<collection-aggregator timeout="5000" failOnTimeout="false" doc:name="Collection Aggregator"/>
<logger message="JDBC Transaction #[message.payload] **************" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="E:\backup\test\ss" outputPattern="#[java.util.UUID.randomUUID().toString()].txt" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>
现在的问题是,当应用程序启动时,它只从数据库中提取 100 行中的 5 行并写入文件,然后不提取剩余的行并且不创建新文件......但我想获取 5每30秒后行并在最后将其写入一个新文件..我做错了什么吗?我已将以下内容作为参考:-如何让 Mule 从 JDBC 查询中将多行作为单个事务返回?
更新流程:-
<flow name="InboundJDBC" doc:name="InboundJDBC" initialState="started">
<jdbc-ee:inbound-endpoint queryTimeout="-1" pollingFrequency="1000" doc:name="Database" connector-ref="Database_Global" queryKey="RetriveQuery">
<jdbc-ee:transaction action="ALWAYS_BEGIN" />
<!-- <property key="receiveMessageInTransaction" value="true"/> --><!-- This to receive all the row in once -->
</jdbc-ee:inbound-endpoint>
<set-property propertyName="#[message.inboundProperties['requestId']]" value="#[java.util.UUID.randomUUID().toString()]" doc:name="Property"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="5"/> <!-- Set the number of rows to be return at a time -->
<add-message-property key="MULE_CORRELATION_ID" value="#[message.inboundProperties['requestId']]"/>
</message-properties-transformer>
<collection-aggregator timeout="5000" failOnTimeout="false" doc:name="Collection Aggregator"/>
<logger message="JDBC Transaction #[message.payload] **************" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="E:\backup\test\ss" outputPattern="#[java.util.UUID.randomUUID().toString()].txt" responseTimeout="10000" doc:name="File"/>
</flow>
现在它正在每行创建文件......