我想同时处理一组消息,但除非我将虚拟机设置为请求-响应,否则我无法使它们成为事务性的……在这种情况下,处理不是并发的。
Mule 文档指出“Mule 事务是在同步端点上配置的”,但我不太了解这个限制。
很明显,在您希望成为事务性的流中,不应产生异步流,但(对我而言)不清楚为什么不能(从非 tx 主流)启动任意数量的异步流交易性的。
换句话说,为什么这可以正常工作:
但是如果我将虚拟机更改为“单向”,它会失败:
org.mule.transaction.IllegalTransactionStateException: Can only bind "javax.sql.DataSource/java.sql.Connection" type resources
有没有解决的办法?
流的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule>
<spring:beans>
<spring:bean id="dataSource" name="dataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName" value="org.h2.Driver" />
<spring:property name="url" value="jdbc:h2:tcp://localhost/~/mule" />
<spring:property name="user" value="sa" />
<spring:property name="password">
<spring:value></spring:value>
</spring:property>
</spring:bean>
<spring:bean id="transactionFactory" name="transactionFactory" class="org.mule.transport.jdbc.JdbcTransactionFactory" />
</spring:beans>
<jdbc:connector name="dbConnector" dataSource-ref="dataSource" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database" />
<flow name="triggerFlow" doc:name="triggerFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" />
<set-payload value="#[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]" doc:name="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"/>
<collection-splitter doc:name="Collection Splitter"/>
<vm:outbound-endpoint exchange-pattern="request-response" path="flow" doc:name="flow" />
</flow>
<flow name="flow" doc:name="flow">
<vm:inbound-endpoint exchange-pattern="request-response" path="flow" doc:name="flow">
<custom-transaction factory-ref="transactionFactory" action="ALWAYS_BEGIN" timeout="10" />
</vm:inbound-endpoint>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="insert" queryTimeout="-1" connector-ref="dbConnector" doc:name="Insert 1">
<jdbc:transaction action="ALWAYS_JOIN" />
<jdbc:query key="insert" value="insert into test values (#[payload], 'Test 1')" />
</jdbc:outbound-endpoint>
<jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="insert2" queryTimeout="-1" connector-ref="dbConnector" doc:name="Insert 2">
<jdbc:transaction action="ALWAYS_JOIN" />
<jdbc:query key="insert2" value="insert into test values (#[payload + 10], 'Test 2')" />
</jdbc:outbound-endpoint>
</flow>
</mule>
提前致谢。