0

I am working with the WSO2 ESB 6.5.0 and am using the fileconnector-2.0.21 version for file operations. The proxy service that I'm building is intended to read the files from a certain source path and merge the contents into a file at the destination path.

The content of the proxy service artifact is below

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="FileMergeProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <log description="Combine files" level="custom" separator="| ">
                <property name="statusMessage" value="Processing complete"/>
                <property name="fileCreation" value="Initiating file merge"/>
                <property expression="$ctx:mergeDirPath" name="sourceDir"/>
                <property expression="$ctx:finalDirPath" name="destDir"/>
                <property expression="$ctx:outputFilePattern" name="pattern"/>
                <property expression="fn:concat('file:///', $ctx:mergeDirPath)" name="sourceDir1" scope="default" type="STRING"/>
                property expression="fn:concat('file:///', $ctx:finalDirPath)" name="destDir1" scope="default" type="STRING"/>
                </log>
                <fileconnector.mergeFiles>
                    <source>{$ctx:mergeDirPath}</source>
                    <destination>{$ctx:finalDirPath}</destination>
                    <filePattern>{$ctx:outputFilePattern}</filePattern>
                </fileconnector.mergeFiles>
                <log description="Processing complete" level="custom" separator="| ">
                    <property name="doneMessage" value="File merge processing complete"/>
                </log>
        </inSequence>
        <outSequence/>
        <faultSequence>
            <log level="custom">
                <property name="text" value="An unexpected error occured"/>
                <property expression="get-property('ERROR_MESSAGE')" name="message"/>
                <property expression="get-property('ERROR_DETAIL')" name="errordetail"/>
            </log>
            <send description="Send Error Information"/>
        </faultSequence>
    </target>
</proxy>

I'm invoking the service with the following parameters as a JSON file

{
  "mergeDirPath": "C://temp//merge//",
  "finalDirPath": "C://temp//final//finalcontent.txt",
  "outputFilePattern": "\\*txt"
}

When I call the service after deploying the artifacts to the ESB engine, it creates an empty file in the destination path without merging the contents of the files in the source directory. This is the extract from the WSO2 logs.

[2020-03-23 12:48:36,683] []  INFO - LogMediator To: /services/FileMergeProxy,MessageID: urn:uuid:b569ec6a-d4fe-4763-a0ca-fb2eb868a31e correlation_id : a1c542bb-7fac-4e0b-9582-8cb1a605f618,Direction: request,Payload: { "mergeDirPath": "C://temp//merge//",  "finalDirPath": "C://temp//final//finalcontent.txt",  "outputFilePattern": "\\*txt" }
[2020-03-23 12:49:00,422] []  INFO - LogMediator statusMessage = Combine files| fileCreation = Initiating file merge| sourceDir = C://temp//merge//| destDir = C://temp//final//finalcontent.txt| pattern = \*txt| sourceDir1 = file:///C://temp//merge//| destDir1 = file:///C://temp//final//finalcontent.txt
[2020-03-23 12:49:02,943] []  INFO - LogMediator doneMessage = File merge processing complete

Unless I'm missing something here, shouldn't the mergeFiles be doing exactly that - merge the contents of files in a specified directory ? Any helpful suggestions or pointers are welcome. Thanks in advance.

Community
  • 1
  • 1
  • Hi @Tech Fiddler, Did you find out the solution for this? I am also trying to merge CSV files, the only an empty CSV file is getting created in the target folder, content is not getting merged – Justin Mar 26 '22 at 07:50

1 Answers1

2

According to the proxy you have shared, you have defined properties inside the log mediator. Define the properties outside the log mediator.

  • Thank you for the suggestion. However this didn't work either. It's as if the sequence just ignores that particular step and proceeds to the next one in the sequence. – Tech Fiddler Apr 06 '20 at 13:41