我需要手动控制跨多个DB调用的事务流,需要顺序执行
我的用例:
我无法使事务调解器与DSS一起使用。如果我尝试在流程结束时强制回滚,则会在日志中收到警告,并将记录保留在数据库中。
[EI-Core] WARN - ROLLBACK Some How TX null
序列:
<transaction action="new"/>
<log level="custom">
<property name="DB_CALL" value="CreateIdentifier"/>
</log>
<payloadFactory media-type="xml">
<format>
<xs:createIdentifier xmlns:xs="cz.example">
<xs:entity>$1</xs:entity>
<xs:partner>$2</xs:partner>
<xs:value>$3</xs:value>
<xs:pair_id>$4</xs:pair_id>
</xs:createIdentifier>
</format>
<args>
<arg evaluator="xml" expression="$func:entity"/>
<arg evaluator="xml" expression="$func:partner"/>
<arg evaluator="xml" expression="$func:value"/>
<arg evaluator="xml" expression="$func:pair_id"/>
</args>
</payloadFactory>
<call>
<endpoint key="Database"/>
</call>
<log level="custom">
<property name="DB CALL" value="UpdateInputProcessedAt"/>
</log>
<payloadFactory media-type="xml">
<format>
<xs:updateInputProcessedAt xmlns:xs="cz.example">
<xs:id>$1</xs:id>
<xs:processed_at>$2</xs:processed_at>
</xs:updateInputProcessedAt>
</format>
<args>
<arg evaluator="xml" expression="$func:id"/>
<arg evaluator="xml" expression="$func:processed_at"/>
</args>
</payloadFactory>
<call>
<endpoint key="Database"/>
</call>
<transaction action="rollback"/>
DSS:
<data enableBoxcarring="true" enableDTP="true" name="DataService" serviceNamespace="cz.example" transports="local http https">
<config id="config">
<property name="driverClassName">org.postgresql.Driver</property>
<property name="url">jdbc:postgresql://url.com</property>
<property name="username">user</property>
<property name="password">pw</property>
</config>
<query id="insert_identifier" useConfig="config">
<sql>INSERT INTO identifiers(entity, partner, value, pair_id) VALUES(?, ?, ?, ?)</sql>
<param name="entity" sqlType="STRING"/>
<param name="partner" sqlType="STRING"/>
<param name="value" sqlType="STRING"/>
<param name="pair_id" sqlType="INTEGER"/>
</query>
<query id="update_input_processed_at" useConfig="config" returnUpdatedRowCount="true">
<sql>UPDATE inputs SET processed_at = ? WHERE id = ?</sql>
<param name="processed_at" sqlType="TIMESTAMP"/>
<param name="id" sqlType="INTEGER"/>
</query>
<operation name="createIdentifier">
<call-query href="insert_identifier">
<with-param name="entity" query-param="entity"/>
<with-param name="partner" query-param="partner"/>
<with-param name="value" query-param="value"/>
<with-param name="pair_id" query-param="pair_id"/>
</call-query>
</operation>
<operation name="updateInputProcessedAt">
<call-query href="update_input_processed_at">
<with-param name="id" query-param="id"/>
<with-param name="processed_at" query-param="processed_at"/>
</call-query>
</operation>
</data>