繁体   English   中英

WSO2 Api Manager序列写入文件不起作用

[英]WSO2 Api Manager sequence to write to a file is not working

最近,我们开始研究WSO2 Api Manager,并希望创建故障流程序列,该流程将有关故障的一些信息写入位于文件系统中的文件中。 WSO2 API Manager安装适用于Windows

我按照此停靠页上的文档步骤进行操作,以启用VFS传输。 然后,我在码头上按照以下示例创建了文件代理和文件写入序列(我跳过了数据库和文件读取器,因为我不需要它们):

<sequence xmlns="http://ws.apache.org/ns/synapse" name="fileWriteSequence">
<log level="custom">
    <property name="sequence" value="fileWriteSequence"/>
</log>
<property xmlns:ns2="http://org.apache.synapse/xsd" name="transport.vfs.ReplyFileName" expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" scope="transport"/>
<property xmlns:ns2="http://org.apache.synapse/xsd" name="transport.vfs.Locking" value="disable" scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<send>
    <endpoint name="FileEpr">
        <address uri="vfs:file:///C:/home/username/test/out"/>
    </endpoint>
</send>

我已经创建了API并成功上传了序列,看起来好像已按预期触发了该事件,但未创建文件-这是该过程的日志:

[2017-03-10 08:27:02,525]  INFO - LogMediator sequence = fileWriteSequence
[2017-03-10 08:27:03,384] ERROR - VFSUtils Cannot get the lock for the file : file:///C:/home/username/test/out/* before processing
[2017-03-10 08:27:03,385]  WARN - VFSTransportSender Couldn't get the lock for the file : file:///C:/home/username/test/out/*, retry : 1 scheduled after : 30000

首先,我认为这是权限问题,但是我为该位置的匿名用户授予了完全控制权,并以管理员身份运行WSO2 AM进程-仍然没有运气。

UPDATE

我通过禁用全局配置(axis2)中的文件锁定来进行变通

<transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender">
<parameter name="transport.vfs.Locking">disable</parameter>
</transportSender>

它仍然不起作用,但是错误略有不同(仍然抱怨路径)。

Caused by: java.io.FileNotFoundException: C:\home\username\test\out\* (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:142)
    at org.apache.commons.vfs2.provider.local.LocalFile.doGetOutputStream(LocalFile.java:251)
    at org.apache.commons.vfs2.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1399)

您可能会注意到,末尾有"*" ,对于整个文件路径都找不到,我并不感到惊讶,但是它是由lib添加的,因此很可能是预期的。

是否有人对WSO2 ESB / AM有任何经验,并且知道如何解决? 这可能是微不足道的,但是经过多次尝试,我找不到解决方案。

您的配置为我工作,看看:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="writeFile"
       transports="http https"
       startOnLoad="true">
   <target>
      <inSequence>
         <payloadFactory media-type="xml">
            <format>
               <moc:QRY_SELECT_SRH_PERSONA xmlns:moc="http://www.example.org/mockWS/">
                  <INT_ID xmlns="">1</INT_ID>
               </moc:QRY_SELECT_SRH_PERSONA>
            </format>
            <args/>
         </payloadFactory>
         <log level="custom">
            <property name="sequence" value="fileWriteSequence"/>
         </log>
         <property xmlns:ns2="http://org.apache.synapse/xsd"
                   name="transport.vfs.ReplyFileName"
                   expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')"
                   scope="transport"/>
         <property name="transport.vfs.Locking" value="disable" scope="transport"/>
         <property name="OUT_ONLY" value="true"/>
         <send>
            <endpoint name="FileEpr">
               <address uri="vfs:file:///C:/home/username/test/out"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence/>
      <faultSequence>
         <log level="custom">
            <property name="text" value="Error Sequence FAIL"/>
            <property name="message" expression="get-property('ERROR_MESSAGE')"/>
            <property name="code" expression="get-property('ERROR_CODE')"/>
            <property name="detail" expression="get-property('ERROR_DETAIL')"/>
            <property name="exception" expression="get-property('ERROR_EXCEPTION')"/>
         </log>
      </faultSequence>
   </target>
</proxy>

我在C:\\ home \\ username \\ test \\ out \\ 8a11314c-4c22-4ad3-bbfc-4fb56ba415a0.txt中的文件具有以下内容:

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><moc:QRY_SELECT_SRH_PERSONA xmlns:moc="http://www.example.org/mockWS/"><INT_ID>1</INT_ID></moc:QRY_SELECT_SRH_PERSONA></soapenv:Body></soapenv:Envelope>

更新1:

代理配置之外的序列:

<sequence name="faultSEQ" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
         <payloadFactory media-type="xml">
            <format>
               <moc:QRY_SELECT_SRH_PERSONA xmlns:moc="http://www.example.org/mockWS/">
                  <INT_ID xmlns="">1</INT_ID>
               </moc:QRY_SELECT_SRH_PERSONA>
            </format>
            <args/>
         </payloadFactory>
         <log level="custom">
            <property name="sequence" value="fileWriteSequence"/>
         </log>
         <property xmlns:ns2="http://org.apache.synapse/xsd"
                   name="transport.vfs.ReplyFileName"
                   expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')"
                   scope="transport"/>
         <property name="transport.vfs.Locking" value="disable" scope="transport"/>
         <property name="OUT_ONLY" value="true"/>
         <send>
            <endpoint name="FileEpr">
               <address uri="vfs:file:///C:/home/username/test/out"/>
            </endpoint>
         </send>
</sequence>

所以最终我能够“修复”此问题,但不能完全解决。

结果表明, "*"来自我为WSO2 API管理器中访问的API创建的端点。 因此,一旦添加了新的端点(资源),例如"/test" ,序列就会在指定的路径下使用所需的内容创建一个文件“ test”。 这仍然很不理想,因为看起来API Manager只是忽略了ReplyFileName参数。 不过,可以说我已经解决了主要问题,因此我将从这一点开始进一步研究。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM