WSO2 Enterprise Integrator 6.3.0:如何将多个文件合并为一个?

WSO2 Enterprise Integrator 6.3.0: how to merge mutliple files to one?

我正在尝试创建一个与 WSO EI 6.3.0 的集成方案,但有以下方案但无法正常工作:

我创建了一个代理来读取 CSV 文件并将它们推送到 inSequence。 .我尝试了什么:

我即将到达聚合器步骤,但我不会越过它。

我做错了什么?或者这个用例可能无法通过 WSO2 EI 实现?

在我的代码下方找到。提前感谢你们的支持。

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="FileReaderProxy" startOnLoad="true" transports="vfs" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <property name="AggregatedResponses" scope="default">
                <metasyst/>
            </property>
            <property description="Get File Name" expression="$trp:FILE_NAME" name="fileName" scope="default" type="STRING"/>
            <log description="Enter In Sequence" level="full">
                <property name="Step" value="Enter In Sequence"/>
                <property expression="get-property('fileName')" name="Filename : "/>
            </log>
            <clone continueParent="true" id="csvFileSet">
                <target>
                    <sequence>
                        <property description="Get File Name" expression="$trp:FILE_NAME" name="fileName" scope="default" type="STRING"/>
                        <log description="Enter Order Clone Branch" level="full">
                            <property name="Step" value="Enter Order Clone Branch"/>
                            <property expression="get-property('fileName')" name="Reading File : "/>
                        </log>
                        <filter xpath="get-property('fileName')='auftraege.csv'">
                            <then>
                                <smooks config-key="conf:myresources/order-smooks-config.xml">
                                    <input type="text"/>
                                    <output type="xml"/>
                                </smooks>
                                <log description="Exit Order Clone Branch" level="full">
                                    <property name="Step" value="Exit Order Clone Branch"/>
                                </log>
                            </then>
                            <else>
                                <log description="Drop Order Clone Branch" level="full">
                                    <property name="Step" value="Drop Order Clone Branch"/>
                                </log>
                                <drop/>
                            </else>
                        </filter>
                    </sequence>
                </target>
                <target>
                    <sequence>
                        <property description="Get File Name" expression="$trp:FILE_NAME" name="fileName" scope="default" type="STRING"/>
                        <log description="Enter Customer Clone Branch" level="full">
                            <property name="Step" value="Enter Customer Clone Branch"/>
                            <property expression="get-property('fileName')" name="Reading File : "/>
                        </log>
                        <filter xpath="get-property('fileName')='kunden.csv'">
                            <then>
                                <smooks config-key="conf:myresources/customer-smooks-config.xml">
                                    <input type="text"/>
                                    <output type="xml"/>
                                </smooks>
                                <log description="Exit Customer Clone Branch" level="full">
                                    <property name="Step" value="Exit Customer Clone Branch"/>
                                </log>
                            </then>
                            <else>
                                <log description="Exit Customer Clone Branch" level="full">
                                    <property name="Step" value="Exit Customer Clone Branch"/>
                                </log>
                                <drop/>
                            </else>
                        </filter>
                    </sequence>
                </target>
            </clone>
            <log description="Enter aggregation" level="full">
                <property name="Step" value="Enter aggregation"/>
            </log>
            <property name="AggregatedResponses" scope="default">
                <metasyst/>
            </property>
            <aggregate id="csvFileSet">
                <completeCondition>
                    <messageCount max="-1" min="2"/>
                </completeCondition>
                <onComplete enclosingElementProperty="AggregatedResponses" expression="$body/*[1]" xmlns:ns="http://org.apache.synapse/xsd">
                    <log description="Start Output File Writing" level="full">
                        <property name="Step" value="Start Output File Writing"/>
                    </log>
                    <property description="OUT_ONLY" name="OUT_ONLY" scope="default" type="STRING" value="true"/>
                    <send>
                        <endpoint>
                            <address uri="vfs:file:///D:/Programme/WSO2-EI/Samples/files/4-out"/>
                        </endpoint>
                    </send>
                </onComplete>
            </aggregate>
        </inSequence>
        <outSequence/>
        <faultSequence>
            <drop/>
        </faultSequence>
    </target>
    <parameter name="transport.PollInterval">1</parameter>
    <parameter name="transport.vfs.FileURI">file:///D:/Programme/WSO2-EI/Samples/files/1-in</parameter>
    <parameter name="transport.vfs.ContentType">text/plain</parameter>
    <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
    <parameter name="transport.vfs.MoveAfterFailure">file:///D:/Programme/WSO2-EI/Samples/files/3-error</parameter>
    <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
    <parameter name="transport.vfs.FileNamePattern">.*.csv</parameter>
    <parameter name="transport.vfs.MoveAfterProcess">file:///D:/Programme/WSO2-EI/Samples/files/2-success</parameter>
</proxy>

使用 VFS 一次只能处理一个文件,从它正在侦听的位置拾取的每个文件都会启动一个新线程。基本上这是给您的代理的新消息。

相反,您可以使用 file connector 来解决这个问题。根据您的要求以及您识别文件集的方式,您仍然可以使用 vfs 来触发该过程,然后使用文件连接器来收集其他文件。或者让计划任务触发您的服务,然后使用文件连接器以给定的时间间隔查找一组文件。

要获得更详尽的答案,我必须更多地了解您要处理的文件集、文件名模式、是否每次都有一定数量的文件等。

希望对您有所帮助