0

下面是我在 Anypoint Studio 中的小程序的配置 xml。我想要做的是将一个文本文件数据(管道分隔)复制到另一个文本文件。执行顺利,但停止在“已部署”状态。我也尝试过其他转换,但结果是一样的。帮助是非常可观的。提前致谢。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">

    <flow name="texttoexcelFlow" doc:id="42aaa83a-e26a-4f6d-8d2f-da3613a8d232" initialState="started">
        <file:read doc:name="Read" doc:id="89fa46c9-aa14-4a79-b7ab-e609b9fad501" path="D:\Mulesoft Input\Name.txt" outputMimeType="application/json" outputEncoding="UTF-8">
            <repeatable-in-memory-stream />
        </file:read>
        <ee:transform doc:name="Transform Message" doc:id="86dc86b8-99ed-4bee-b5bc-e07616e44431" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/csv headerLineNumber = 0 , header = false , separator = "|"
---
payload map ( payload01 , indexOfPayload01 ) -> {
    FirstName: payload01.FirstName ,
    LastName: payload01.LastName
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <file:write doc:name="Write" doc:id="3884725e-3870-4ef1-9e05-b10a2274dfa6" path="C:\Users\aseem\Desktop\Mulesoft Output\Excel.txt">
        </file:write>
    </flow>
</mule>
"
4

1 回答 1

0

您需要一些东西来触发流程运行。file:read不会自动执行此操作。

flow-ref所有流都需要一个“源”来触发它们,除非您使用(或使用lookup()从dataweave)从其他流中调用它们。

如果您知道所需的确切文件,则可以在file:read触发流程之前放置一个调度程序:

<scheduler>
  <scheduling-strategy>
    <fixed-frequency startDelay="5" frequency="10" timeUnit="SECONDS"/>
  </scheduling-strategy>
</scheduler>

或者您可以使用 file:listener 直接监听目录等中的新文件作为源:

<flow name="onNewFile">
  <file:listener config-ref="file" directory="test-data/in" autoDelete="true">
    <scheduling-strategy>
      <fixed-frequency frequency="1000"/>
    </scheduling-strategy>
  </file:listener>
  ...
</flow>

您可以使用固定频率或 cron。更多细节在这里:https ://docs.mulesoft.com/mule-runtime/4.1/scheduler-xml-reference

于 2019-02-28T22:29:04.610 回答