是否可以将Enterprise Integrator中的事务介体与DSS payloadFactory + Call一起使用?

时间:2019-02-21 11:03:09

标签: wso2 wso2dss wso2ei synapse

我需要手动控制跨多个DB调用的事务流,需要顺序执行

我的用例:

  • 创建交易
  • 将记录插入表
  • 根据前一次插入返回的ID,更新其他表中的记录
  • 如果一切都通过了,则提交事务,或者在发生任何错误的情况下回滚

我无法使事务调解器与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>

0 个答案:

没有答案