WSo2 Esb filtering messages to an output file

2019-08-30 11:24发布

问题:

I am working with a filter mediator attempting to send messages to an output xml file. I have my sequence using a filter mediator based on a attribute value, if it is true I want to write the message to a new xml file in a certain directory. If it is false I will drop the record. Here is my sequence:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="RenaissanceIqtFilterSequence">
   <log level="custom">
      <property name="sequence" value="FilterSequence"></property>
   </log>
   <filter xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:ns="http://org.apache.synapse/xsd" xmlns:z="RowsetSchema" xpath="//z:row/@name='RP'">
      <then>
         <log level="custom">
            <property name="sequence" value="Condition Write"></property>
         </log>
         <call-template target="FileWriteTemplate">
            <with-param name="targetFileName" value="NEW_MESSAGE_FILE"></with-param>
            <with-param name="addressUri" value="vfs:file:///var/process/rrout"></with-param>
         </call-template>
      </then>
      <else>
         <log level="custom">
            <property name="sequence" value="Condition Drop"></property>
         </log>
         <drop></drop>
      </else>
   </filter>
</sequence>

*I am using a template as you can see to write out to my new output file setting parameters for the file name and uri.

The result is the whole file is being written out to the directory not just the messages I want. I have been running google searches trying to see where I am going wrong. I assume at this point I may be using the Filter mediator incorrectly? Maybe there is a better way or mediator to use to accomplish this task? I would appreciate any thoughts or recommendations folks may have. Thanks for your time!