mule - NullPayload for Database Query only when wrapped in a Transaction -
i have flow returns nullpayload when wrapped in multi-transaction. when remove multi-transaction tag expected results. why that? here code snippet
<flow name="successful-flow" processingstrategy="synchronous"> <vm:inbound-endpoint exchange-pattern="request-response" path="order-process.in" doc:name="vm"/> <ee:multi-transactional action="always_begin" doc:name="transactional" > <foreach collection="#[message.payload]" doc:name="for each" rootmessagevariablename="original"> <jms:outbound-endpoint queue="orders.queue" connector-ref="jmsconnector" doc:name="jms - send order processing queue"> <jms:transaction action="join_if_possible"/> </jms:outbound-endpoint> </foreach> <db:insert config-ref="order_db" doc:name="save orders" > <db:parameterized-query><![cdata[insert orders(product_id,line_item_code,price,lst_updt_tmsp) values('xxt665,'tp',20.99,'09/09/2010')]]></db:parameterized-query> </db:insert> </ee:multi-transactional> <response> <db:select config-ref="order_db" doc:name="database" transactionalaction="always_join"> <db:parameterized-query><![cdata[select count(*) orders]]></db:parameterized-query> </db:select> </response> <catch-exception-strategy doc:name="order processing exception"> <logger message="error during flow - #[message] :: exception::= # [exception.summarymessage]" level="error" doc:name="logger" /> </catch-exception-strategy> </flow>
my bad, previous transaction not have finished , been committed. default transactionalaction select query join_if_possible means reading data before data inserted , committed. simple fix follows:
<response> <db:select config-ref="order_db" doc:name="database" transactionalaction="not_supported"> <db:parameterized-query><![cdata[select count(*) orders]]></db:parameterized-query> </db:select> </response>
Comments
Post a Comment