2

我有一个骡子流如下

<flow name="flow1" doc:name="f1">
    <file:inbound-endpoint path="C:\input" responseTimeout="10000"
        doc:name="File" />
</flow>

<flow name="flow2" doc:name="f2">
    <http:inbound-endpoint address="http://localhost:8080"
        doc:name="HTTP" exchange-pattern="request-response" />
    <flow-ref name="flow1" doc:name="Flow Reference" />
    <file:outbound-endpoint path="C:\outputfile"
        responseTimeout="10000" doc:name="File" />
</flow>

我正在尝试通过使用流程将多个文件从源移动/上传到目标(可以是任何东西,例如 FTP 或文件出站等)。

这样做的原因是我想使用 CURL 从 CLI(命令行界面)调用作业。

但它不工作....

已编辑

我需要从位于我的硬盘驱动器中的特定文件夹中提取一些文件(多个文件)。然后将它们移动到一些出站进程,可以是 FTP 站点或其他硬盘驱动器位置。但是这个流程需要从 CLI 中调用。

编辑(基于大卫的回答)

我现在有如下流程

<flow name="filePickupFlow" doc:name="flow1" initialState="stopped">
     <file:inbound-endpoint path="C:\Input" responseTimeout="10000" doc:name="File"/>
            
      <logger message="#[message.payloadAs(java.lang.String)]" level="ERROR" />
</flow>

<flow name="flow2" doc:name="flow2">
  <http:inbound-endpoint address="http://localhost:8080/file-pickup/start" doc:name="HTTP" exchange-pattern="request-response"/>
  
  <expression-component>
        app.registry.filePickupFlow.start();
    </expression-component>
 
 <file:outbound-endpoint path="C:\outputfile" responseTimeout="10000" doc:name="File"/>

</flow>

我遇到了几个问题

a) 我收到一个错误 -属性 initialState 未定义为流的有效属性

在此处输入图像描述

但是,如果我删除该属性,则流程会继续,而无需等待"http://localhost:8080/file-pickup/start"启动。

b) 文件未移动到目标文件夹

那么我该怎么做呢?

4

3 回答 3

4

您无法引用其中包含入站端点的流,因为此类流已经处于活动状态并正在使用来自其入站端点的事件,因此您无法按需调用它。

以下在 Mule 3.3.1 上进行了测试,展示了如何根据 HTTP 请求启动“文件提取流程”。

<flow name="filePickupFlow" initialState="stopped">
    <file:inbound-endpoint path="///tmp/mule/input" />
    <!-- Do something with the file: here we just log its content -->
    <logger message="#[message.payloadAs(java.lang.String)]" level="ERROR" />
</flow>

<flow name="filePickupStarterFlow">
    <http:inbound-endpoint address="http://localhost:8080/file-pickup/start"
        exchange-pattern="request-response" />
    <expression-component>
        app.registry.filePickupFlow.start();
    </expression-component>
    <set-payload value="File Pickup successfully started" />
</flow>

然后HTTP GETtinghttp://localhost:8080/file-pickup/startfilePickupFlow启动/tmp/mule/input.

请注意,您可以file:connector为其处理的文件配置必须具有的行为,删除它们或将它们移动到另一个目录是两个主要选项。

于 2013-01-31T19:20:52.360 回答
0

我猜在这种情况下,按需读取文件的入站文件将无济于事。

请尝试以下方式。

<flow name="flow1" doc:name="f2">
    <http:inbound-endpoint address="http://localhost:8080"
        doc:name="HTTP" exchange-pattern="request-response" />
    <component>
        <spring-object bean="fileLoader"></spring-object>
    </component>
   <file:outbound-endpoint path="C:\outputfile"
       responseTimeout="10000" doc:name="File" />
</flow>

因此,自定义组件将是一个从您指定位置读取文件的类。

希望这可以帮助。

于 2013-02-01T15:36:21.157 回答
0

您可以使用 Mule Requester 获得干净的解决方案。请参阅博客条目介绍 Mule 请求者中的详细信息。

于 2014-10-14T17:30:36.807 回答