1

好的,这是我原来问题的延续。(WSo2 Esb 将消息过滤到输出文件)在对迭代和聚合调解器进行了几天的研究之后,我已经到达了进度墙,并且非常感谢任何关于如何解决我的阻塞问题的建议。手头的任务很简单,读取 xml 文件,过滤某些记录,然后只生成一个输出 xml 文件,其中包含那些符合条件的记录。经过先前的讨论和研究,此任务解决方案如下:使用迭代中介访问每个 xml 记录并使用过滤中介来决定我要保留的内容。然后使用聚合器调解器将所有这些记录写入 1 个文件。如果没有聚合器,我的配置会为每个文件生成 1 条记录。这是我在这种状态下的代理:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="RenFileFilterProxy"
       transports="vfs"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full"/>
         <clone>
            <target sequence="RenIqtFilterSequence"/>
         </clone>
      </inSequence>
      <outSequence>
         <log level="custom">
            <property name="sequence" value="In the outSequence"/>
         </log>
         <log level="full"/>
         <aggregate id="QuizType">
            <completeCondition>
               <messageCount min="-1" max="-1"/>
            </completeCondition>
            <onComplete xmlns:z="RowsetSchema" expression="//z:row">
               <call-template target="FileWriteTemplate">
                  <with-param name="targetFileName" value="TEST_FILE"/>
                  <with-param name="addressUri" value="vfs:file:///var/process/ren/rrout"/>
               </call-template>
            </onComplete>
         </aggregate>
      </outSequence>
   </target>
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.PollInterval">15</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file:///var/process/ren/extractedfiles</parameter>
   <parameter name="transport.vfs.FileURI">file:///var/process/ren/extractedfiles</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file:///var/process/ren/failure</parameter>
   <parameter name="transport.vfs.FileNamePattern">test.xml</parameter>
   <parameter name="transport.vfs.ContentType">application/xml</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
   <description/>
</proxy> 

这是 RenIqtFilterSequence:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="RenIqtFilterSequence">
   <log level="custom">
      <property name="sequence" value="RenIqtFilterSequence"></property>
   </log>
   <iterate xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" xmlns:z="RowsetSchema" expression="//z:row" id="QuizType">
      <target>
         <sequence>
            <log>
               <property name="iteratesequence" value="Iterating through the the records"></property>
            </log>
            <filter xmlns:rs="urn:schemas-microsoft-com:rowset" xpath="//z:row/@name='RP'">
               <then>
                  <log level="custom">
                     <property name="sequence" value="Condition Write"></property>
                  </log>
                  <log level="full"></log>
                  <log level="custom">
                     <property name="sequence" value="Getting ready to aggregate"></property>
                  </log>
               </then>
               <else>
                  <log level="custom">
                     <property name="sequence" value="Condition Drop"></property>
                  </log>
                  <drop></drop>
               </else>
            </filter>
         </sequence>
      </target>
   </iterate>
</sequence>

我现在面临的问题是我无法使用 outSequence 来执行我的聚合器逻辑。事实是我不需要从 inSequence 为这个过程调用后端服务,所以我正在努力寻找一种干净的方式来访问我的 outSequence。有什么推荐吗?我试图在我的 inSequence 中包含聚合器调解器,但它不起作用,没有产生任何输出。我认为聚合器需要在 outSequence 中以捕获我过滤的所有记录,然后我可以将它们全部写入 1 个文件。我相信我需要在这里进行一些配置:

            <filter xmlns:rs="urn:schemas-microsoft-com:rowset" xpath="//z:row/@name='RP'">
               <then>
                  <log level="custom">
                     <property name="sequence" value="Condition Write"></property>
                  </log>
                  <log level="full"></log>
                  <log level="custom">
                     <property name="sequence" value="Getting ready to aggregate"></property>
                  </log>
===============> Need to transfer to OutSequence somehow here!!!!<============
               </then>
               <else>

我已经尝试了几种基于在线文章和博客的方法,但我无法将最后的部分放在适当的位置。任何建议将不胜感激。感谢您花时间阅读本文。

4

0 回答 0