Mule フローがあり、データベースから行をフェッチしてファイルに書き込む必要があります。現在、データベースには 100 行あり、DB から一度に 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>
問題は、アプリケーションの起動時に、DB から 100 行のうち 5 行のみをフェッチしてファイルに書き込み、残りの行がフェッチされず、新しいファイルが作成されないことです...しかし、5 をフェッチしたい30秒ごとに行を削除し、最後に新しいファイルに書き込みます..私は何か間違ったことをしていますか?? 以下を参考にしました:- Mule が JDBC クエリから複数の行を 1 つのトランザクションとして返すようにするにはどうすればよいですか?
更新されたフロー:-
<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>
現在、行ごとにファイルを作成しています...