使用Mule工作流和文件端点写入$ {app.home}

时间:2014-04-11 18:11:18

标签: rss mule

我有一个groovy脚本生成一个RSS源,我试图使用文件端点写入$ {app.home} / rss。

然后我通过http端点将此RSS提要作为静态资源提供。

<flow name="rssModifier" doc:name="rssModifier">
    <quartz:inbound-endpoint jobName="job" repeatInterval="300000" responseTimeout="10000" doc:name="Quartz">
        <quartz:event-generator-job/>
    </quartz:inbound-endpoint>
    <all doc:name="All">
        <processor-chain>
            <scripting:component doc:name="FirstGroovyRssFeed">
                <scripting:script engine="Groovy" file="C:\git-gms\edus-esb-rss-test-harness\src\main\java\edu\ucdavis\iet\edus\rsstestharness\server\groovy\InitializeRssFeed.groovy"/>
            </scripting:component>
            <logger message="#[payload]" level="INFO" doc:name="Logger"/>
            <file:outbound-endpoint path="${app.home}/rss/groovy.xml" responseTimeout="10000" doc:name="File"/>
        </processor-chain>

    </all>
</flow>

<flow name="httpWebServer" doc:name="httpWebServer">
    <http:inbound-endpoint address="http://localhost:8084/static" doc:name="HTTP" exchange-pattern="request-response" connector-ref="HTTP_HTTPS"/>
    <http:static-resource-handler resourceBase="${app.home}/rss" 
           defaultFile="rometest.xml" doc:name="HTTP Static Resource Handler"/>
    <logger message="#[payload] #[message]" level="INFO" doc:name="Logger"/>
</flow>

我确认运行此应用程序时,$ {app.home}目录中存在groovy.xml文件,但是我收到以下错误,并且rss feed xml没有被写入文件:

    Message               : Streaming failed. Could not get output stream. Failed to route    event via endpoint: DefaultOutboundEndpoint{endpointUri=file:///C:/Users/gmsharpe/MuleStudio/workspace-3.5/.mule/apps/edus-esb-rss-test-harness/rss/groovy.xml, connector=FileConnector
{
  name=output
  lifecycle=start
  this=353ccb63
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}
,  name='endpoint..C.Users.gmsharpe.MuleStudio.workspace.3.5.mule.apps.edus.esb.rss.test.harness.rss.groovy.xml', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
  1. The system cannot find the path specified (java.io.IOException)
  java.io.WinNTFileSystem:-2 (null)
2. Streaming failed. Could not get output stream. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:///C:/Users/gmsharpe/MuleStudio/workspace-3.5/.mule/apps/edus-esb-rss-test-harness/rss/groovy.xml, connector=FileConnector
{
  name=output
  lifecycle=start
  this=353ccb63
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}
,  name='endpoint..C.Users.gmsharpe.MuleStudio.workspace.3.5.mule.apps.edus.esb.rss.test.harness.rss.groovy.xml', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String (org.mule.api.transport.DispatchException)
  org.mule.transport.file.FileConnector:569 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at org.mule.util.FileUtils.createFile(FileUtils.java:93)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

1 个答案:

答案 0 :(得分:0)

我弄清楚我做错了什么。我只需要定义文件出站端点的目录路径。我还需要一个文件连接器,定义如下:

<file:connector name="output" autoDelete="false" outputAppend="true" outputPattern="groovy.xml" streaming="false" validateConnections="true" doc:name="File"/> 

文件连接器配置为允许附加到现有文件(如果存在),并通过&quot; outputPattern&#39;来定义文件的名称。属性。