使用聚合消息*(没有continueParent)聚合*后退出迭代中介 - WSO2

问题描述 投票:0回答:1

是否有可能在迭代+聚合中介与聚合消息之后继续流程,以便我可以继续使用生成的消息?

或者我是否必须在聚合介体中进行所有处理并使用continueParent属性以其他方式继续处理?

我想要实现的示例代码。请注意,我不能执行迭代序列以外的任何内容(即使我使用continueParent =“true”,下面记录的有效负载不是迭代+聚合有效负载,但事实证明它是迭代前的有效负载) ...:

<iterate description="" expression="//n1:Entry" id="ENTRY_ITERATOR" 
xmlns:n1="http://ws.apache.org/ns/synapse">
<target>
    <sequence>
        <sequence key="myValidationSequence"/>
        <log>
            <property expression="$ctx:RESULT" name="Validation Result:"/>
        </log>
        <switch source="$ctx:RESULT">
            <case regex="S">
                <drop/>
            </case>
            <case regex="C">
                <payloadFactory media-type="xml">
                    <format>
                        <Entry>
                            <product_code>$1</product_code>
                        </Entry>
                    </format>
                    <!-- this comes from the validationSequence -->
                    <args>
                        <arg evaluator="xml" expression="$ctx:product_code"/>
                    </args>
                </payloadFactory>
            </case>
            <default>
                <log>
                    <property name="Warning: " value="Could not identify validation code."/>
                </log>
            </default>
        </switch>
        <log level="full"/>
        <property name="RESPONSE" value="true"/>
        <sequence key="AggregationSequence"/></sequence>
</target>
</iterate>
<log>
    <property name="INFO" value="I can't get here. Why?"/>
</log>
<log level="full"/>

这是聚合序列:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="AggregationSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <aggregate id="ENTRY_ITERATOR">
        <completeCondition>
            <messageCount max="-1" min="-1"/>
        </completeCondition>
        <onComplete>
            <log>
                <property name="LOG..." value="Aggregation completed"/>
            </log>
            <log level="full"/>
        </onComplete>
    </aggregate>
</sequence>

我的EI版本是6.1.1

loops wso2 wso2esb esb mediator
1个回答
1
投票

是否有可能在迭代+聚合中介与聚合消息之后继续流程,以便我可以继续使用生成的消息? - 是的,这就是使用调解器及其可能性的想法。

以下方式应该有效。

<iterate description="" expression="//n1:Entry" id="ENTRY_ITERATOR" 
xmlns:n1="http://ws.apache.org/ns/synapse">
<target>
    <sequence>
        <sequence key="myValidationSequence"/>
        <log>
            <property expression="$ctx:RESULT" name="Validation Result:"/>
        </log>
        <switch source="$ctx:RESULT">
            <case regex="S">
                <drop/>
            </case>
            <case regex="C">
                <payloadFactory media-type="xml">
                    <format>
                        <Entry>
                            <product_code>$1</product_code>
                        </Entry>
                    </format>
                    <!-- this comes from the validationSequence -->
                    <args>
                        <arg evaluator="xml" expression="$ctx:product_code"/>
                    </args>
                </payloadFactory>
            </case>
            <default>
                <log>
                    <property name="Warning: " value="Could not identify validation code."/>
                </log>
            </default>
        </switch>
        <log level="full"/>
        <property name="RESPONSE" value="true"/>
</target>
</iterate>

    <aggregate id="ENTRY_ITERATOR">
        <completeCondition>
            <messageCount max="-1" min="-1"/>
        </completeCondition>
        <onComplete>
            <log>
                <property name="LOG..." value="Aggregation completed"/>
            </log>
            <log level="full"/>
        </onComplete>
    </aggregate>

请参阅以下Iterate和Aggregate调解员文档,以便更好地理解工作流程。

https://docs.wso2.com/display/EI611/Iterate+Mediator https://docs.wso2.com/display/EI611/Aggregate+Mediator

© www.soinside.com 2019 - 2024. All rights reserved.