0

I have the following flow in Mule 3.3.2:

<flow name="testFlow" processingStrategy="synchronous">
    <vm:inbound-endpoint
            connector-ref="vmConnector"
            path="in">
        <vm:transaction action="ALWAYS_BEGIN"/>
    </vm:inbound-endpoint>

    <transactional action="ALWAYS_BEGIN">
        <jdbc:outbound-endpoint
                connector-ref="jdbcConnector"
                queryKey="insertTest"
        />

        <jdbc:outbound-endpoint
                connector-ref="jdbcConnector"
                queryKey="insertTest2"
        />
        <rollback-exception-strategy/>
    </transactional>

    <vm:outbound-endpoint
            connector-ref="vmConnector"
            path="outErrorQueue">
        <vm:transaction action="ALWAYS_JOIN"/>
    </vm:outbound-endpoint>
 </flow>

What I'm trying to achieve is a jdbc transaction nested into the vm transaction: any exception inside the transactional scope should trigger rollback for the jdbc transaction, propagate to the scope of the transactional flow and trigger the default exception strategy for the vm transaction. Any exception outside of the transactional scope should just trigger the default exception strategy of the flow, of course.

Reading source for e.g. org.mule.transaction.TransactionCoordination leads me to believe that that might work, at least if transactional would accept ACTION_NOT_SUPPORTED as action (which it does not -- can I make it?).

What i get instead is

org.mule.transaction.IllegalTransactionStateException: A transaction is not available for this session, but transaction action is "Always Join"
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:41)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52)

at the vm:outbound-endpoint.

Is there any alternative way to get what I want with Mule?

4

1 回答 1

0

我认为 VM 连接器不支持嵌套事务。

我会尝试在这个用例中使用 XA,因为 XA 事务可以暂停和恢复,这将发生在transactional块的边界:

<jbossts:transaction-manager />

<flow name="testFlow" processingStrategy="synchronous">
    <vm:inbound-endpoint
            connector-ref="vmConnector"
            path="in">
        <xa-transaction action="ALWAYS_BEGIN"/>
    </vm:inbound-endpoint>

    <transactional action="ALWAYS_BEGIN">
        <jdbc:outbound-endpoint
                connector-ref="jdbcConnector"
                queryKey="insertTest"
        />

        <jdbc:outbound-endpoint
                connector-ref="jdbcConnector"
                queryKey="insertTest2"
        />
        <rollback-exception-strategy/>
    </transactional>

    <vm:outbound-endpoint
            connector-ref="vmConnector"
            path="outErrorQueue">
        <xa-transaction action="ALWAYS_JOIN"/>
    </vm:outbound-endpoint>
</flow>
于 2013-04-17T16:49:44.650 回答