WSo2 Esb filtering messages to an output file Part 2

僤鯓⒐⒋嵵緔 提交于 2019-12-11 11:13:53

问题


Ok, this is a continuation to my original question. (WSo2 Esb filtering messages to an output file) After a couple more days of research into the iterate and aggregate mediator I have reached a progress wall and would be very grateful for any advice how to resolve my blocking issue. The task at hand is simple, read and xml file, filter on certain records, and only produce an output xml file with just those records that meet the criteria. After previous discussion and research this tasks solution is as follows: use a iterate mediator to access each xml record and use a filter mediator to decide what I want to keep. Then use a aggregator mediator to write all these records to 1 file. Without the aggregator my configuration is producing 1 record per file. Here is my proxy at this state:

<?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> 

Here is the 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>

The issue I am facing now is I cannot get to the outSequence to perform my aggregator logic. The fact is I do not need to call a backend service for this process from the inSequence so I am struggling to find a clean way to get to my outSequence. Any Recomendations? I tried to include the aggregator mediator in my inSequence but it did not work, no output is produced. I figured the aggregator needs to be in the outSequence to capture all the records I filtered and then I can write them all out to 1 file. I believe I need some configuration here:

            <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>

I have tried several approaches based on articles and blogs online but I just cannot put the final pieces in place. Any advice would be much appreciated. Thank you for your time reading this.

来源:https://stackoverflow.com/questions/32808655/wso2-esb-filtering-messages-to-an-output-file-part-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!