有人请提供有关如何解决以下FileConnector.copy问题的内部和指导吗?我使用的是wso2esb版本4.9和FileConnector2。
我有一个序列,它利用FileConnector2 COPY操作将文件复制到FTP位置。 COPY操作多次将文件复制到目标,即使没有我知道的并发问题!有趣的是,文件复制的次数取决于它运行的环境。在开发环境中,文件被复制了17次。在制作中,文件被复制了200多次。我试图了解驱动这种行为的原因。我是否错误配置了FileConnector的COPY操作?我在下面提供了序列定义和网络流量。非常感谢您的帮助。
执行文件复制的序列定义。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="SendFile2VendorSeq" onError="FileUploadFailSeq"
trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property action="remove" name="ClientApiNonBlocking" scope="axis2"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<dblookup description="Get CDR files to be upload">
<connection>
<pool>
<dsName>jdbc/DB_DS</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[
SELECT QUERY HERE
]]></sql>
<parameter expression="get-property('vendorCode')" type="VARCHAR"/>
<result column="vendor_dest" name="vendorDest"/>
<result column="file_name" name="fileName"/>
<result column="vendor_id" name="vendorId"/>
<result column="file_path" name="fileSource"/>
<result column="vendor_code" name="vendorCode"/>
<result column="id" name="fileId"/>
</statement>
</dblookup>
<!-- CHECK TO SEE IF A ROW IS RETURNED. IF NOT THEN EXIT -->
<filter xpath="boolean(get-property('fileSource'))">
<then>
<property
expression="fn:concat(get-property('fileSource'),get-property('fileName'))"
name="sourceFile" scope="default" type="STRING"/>
<fileconnector.isFileExist>
<source>{$ctx:sourceFile}</source>
</fileconnector.isFileExist>
<switch source="//fileExist">
<case regex="true">
<log description="logEntry" level="full"/>
<!-- Log the transaction in Database -->
<log description="LogEntry" level="custom">
<property
expression="fn:concat('Uploading ', get-property('fileName'), ' (id:', get-property('fileId'), ') to vendor ', get-property('vendorCode'))" name="message"/>
</log>
<dblookup description="LogTX">
<connection>
<pool>
<dsName>jdbc/DB_DS</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[SELECT record_TX(?,?)]]></sql>
<parameter expression="get-property('fileId')" type="INTEGER"/>
<parameter expression="get-property('vendorId')" type="INTEGER"/>
</statement>
</dblookup>
<!-- Conduct file copy -->
<fileconnector.copy>
<source>{$ctx:fileSource}</source>
<destination>{$ctx:vendorDest}</destination>
<filePattern>{$ctx:fileName}</filePattern>
</fileconnector.copy>
<!-- Update the transaction with status -->
<dblookup description="LogTX">
<connection>
<pool>
<dsName>jdbc/DB_DS</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[SELECT record_TX(?,?,?,?)]]></sql>
<parameter expression="get-property('fileId')" type="INTEGER"/>
<parameter expression="get-property('vendorId')" type="INTEGER"/>
<parameter type="CHAR" value="S"/>
<parameter type="VARCHAR" value="Success"/>
</statement>
</dblookup>
<log description="LogEntry" level="custom">
<property
expression="fn:concat('Successfully uploaded ', get-property('fileName'), ' (id:', get-property('fileId'), ') to vendor ', get-property('vendorCode'))" name="message"/>
</log>
<drop/>
</case>
<default>
<log description="LogEntry" level="custom">
<property
expression="fn:concat(get-property('fileName'), ' (id:', get-property('fileId'), ') does not exists in the source directory.')" name="message"/>
</log>
<dblookup description="LogTX">
<connection>
<pool>
<dsName>jdbc/DB_DS</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[SELECT record_TX(?,?,?,?)]]></sql>
<parameter expression="get-property('fileId')" type="INTEGER"/>
<parameter expression="get-property('vendorId')" type="INTEGER"/>
<parameter type="CHAR" value="S"/>
<parameter type="VARCHAR" value="File does not exists in the source directory."/>
</statement>
</dblookup>
</default>
</switch>
</then>
<else>
<drop/>
</else>
</filter>
</sequence>
网络输出样本显示行为。
Mon Jan 30 11:46:00 2017 [pid 21385] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:00 2017 [pid 21384] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:00 2017 [pid 21386] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 66.90Kbyte/sec
Mon Jan 30 11:46:00 2017 [pid 21388] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:00 2017 [pid 21387] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:00 2017 [pid 21389] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 67.74Kbyte/sec
Mon Jan 30 11:46:00 2017 [pid 21392] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:01 2017 [pid 21391] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:01 2017 [pid 21393] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 31.43Kbyte/sec
Mon Jan 30 11:46:01 2017 [pid 21395] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:01 2017 [pid 21394] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:01 2017 [pid 21396] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 64.64Kbyte/sec
Mon Jan 30 11:46:01 2017 [pid 21398] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:01 2017 [pid 21397] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:02 2017 [pid 21399] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 64.84Kbyte/sec
Mon Jan 30 11:46:02 2017 [pid 21401] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:02 2017 [pid 21400] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:02 2017 [pid 21402] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 47.52Kbyte/sec
Mon Jan 30 11:46:02 2017 [pid 21404] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:02 2017 [pid 21403] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:02 2017 [pid 21405] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 58.88Kbyte/sec
Mon Jan 30 11:46:02 2017 [pid 21407] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:03 2017 [pid 21406] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:03 2017 [pid 21408] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 52.50Kbyte/sec
Mon Jan 30 11:46:03 2017 [pid 21410] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:03 2017 [pid 21409] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:03 2017 [pid 21411] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 63.34Kbyte/sec
Mon Jan 30 11:46:03 2017 [pid 21413] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:03 2017 [pid 21412] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21414] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 69.12Kbyte/sec
Mon Jan 30 11:46:04 2017 [pid 21416] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21415] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21417] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 56.66Kbyte/sec
Mon Jan 30 11:46:04 2017 [pid 21419] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21418] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21420] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 66.30Kbyte/sec
Mon Jan 30 11:46:04 2017 [pid 21422] CONNECT: Client "Some-IP-address"
Mon Jan 30 11:46:04 2017 [pid 21421] [userName] OK LOGIN: Client "Some-IP-address"
Mon Jan 30 11:46:05 2017 [pid 21423] [userName] OK UPLOAD: Client "Some-IP-address", "/test/file.T70130IN03.csv", 1607 bytes, 68.93Kbyte/sec
记录系统日志文件中的条目。看起来中介需要2分钟以上才能结束其操作。在这2分钟左右的时间里,它反复将文件一遍又一遍地复制到目的地,直到某种超时,我猜。
[2017-02-02 15:24:58,250] DEBUG - ClassMediator Start : Class mediator
[2017-02-02 15:24:58,250] DEBUG - ClassMediator invoking : class org.wso2.carbon.connector.FileCopy.mediate()
[2017-02-02 15:25:46,851] DEBUG - ThreadingView Thread state summary for PassthroughHttpServerWorker threads - Blocked: 0.0%, Unblocked: 100.0%
[2017-02-02 15:25:46,881] DEBUG - ThreadingView Thread state summary for PassthroughHttpServerWorker threads - Blocked: 0.0%, Unblocked: 100.0%
[2017-02-02 15:26:46,855] DEBUG - ThreadingView Thread state summary for PassthroughHttpServerWorker threads - Blocked: 0.0%, Unblocked: 100.0%
[2017-02-02 15:26:46,884] DEBUG - ThreadingView Thread state summary for PassthroughHttpServerWorker threads - Blocked: 0.0%, Unblocked: 100.0%
[2017-02-02 15:27:29,479] DEBUG - ClassMediator End : Class mediator
[2017-02-02 15:27:29,479] DEBUG - SequenceMediator End : Sequence <CopyFile>
答案 0 :(得分:0)
我在从FileConnector反编译FileCopy.class后找到了解决方案。显然,在中介的配置中指定了filePattern的情况下,存在FOR循环。删除filePattern并在源文件中指定文件后,它按预期工作。
<sequence name="CopyFile" onError="AppDefaultFailSeq" trace="disable"
xmlns="http://ws.apache.org/ns/synapse">
<fileconnector.copy>
<source>c://data/out/testFile.csv</source>
<destination>ftp://userName:{password}@ftp.co.com/test</destination>
</fileconnector.copy>
</sequence>