【问题标题】:moveToDirectory FTP errors- MulemoveToDirectory FTP 错误 - Mule
【发布时间】:2014-09-26 05:52:36
【问题描述】:

使用Mule EE,我有以下项目;

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

<mule xmlns:jdbc-ee="http://www...
    <smtp:gmail-connector name="gmail" doc:name="Gmail"/>
    <db:mysql-config name="MySQL_Configuration" host="localhost"
        port="3306"   database="dbflow"
        doc:name="MySQL Configuration" user="user" password="Pass"/>
    <data-mapper:config name="CSV_To_XML" transformationGraphPath="csv_to_xml.grf" doc:name="CSV_To_XML"/>
    <ftp:connector name="FTP" pollingFrequency="1000" validateConnections="true" moveToDirectory= "C:\Users\User\Desktop\output" doc:name="FTP"/>
    <flow name="dbFlow1" doc:name="dbFlow1">
        <ftp:inbound-endpoint host="localhost" port="21" path="/{path}" user="username" password="pass" responseTimeout="10000" doc:name="FTP" connector-ref="FTP"/>
        <data-mapper:transform config-ref="CSV_To_XML" doc:name="CSV To XML"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <foreach collection="#[xpath('//info')]" doc:name="For Each">
            <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
            <db:insert config-ref="MySQL_Configuration" doc:name="Database">
                <db:parameterized-query><![CDATA[INSERT INTO `dbflow`.`user_table`
(`my_date`,
`serialnumber`,
`gender`,
`fullname`,
`email`,
`mobilenumber`,
`address`)
VALUES
(#[xpath://date],
#[xpath://serialnumber],
#[xpath://gender],
#[xpath://fullname],
#[xpath://email],
#[xpath://mobilenumber],
#[xpath://address]
);]]></db:parameterized-query>
            </db:insert>
            <message-properties-transformer scope="invocation" doc:name="Message Properties">
                <add-message-property key="count" value="#[flowVars.counter]"/>
            </message-properties-transformer>
        </foreach>
        <logger message="Number of records #[flowVars]" level="INFO" doc:name="Logger"/>
        <smtp:outbound-endpoint host="smtp.gmail.com" port="587" user="user10%40gmail.com" password="pass" connector-ref="gmail" to="user2@gmail.com"  subject=Muleapp" responseTimeout="10000" doc:name="Email"/>
    </flow>
</mule>

它工作正常。但是,当我添加 FTP 连接器以使用 moveToDirectory 时,Mule 给我以下错误 NON-STOP!该文件被移动到我想要的目录,但骡子给出了同样的错误无限次!除非我停止运行 Mule,否则它不会停止! 并且 Mule 不会继续流程(插入数据库并发送电子邮件);

ERROR 2014-08-03 21:00:56,113 [[tests].FTP.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
java.io.IOException: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
    at com.mulesoft.mule.transport.ftp.EEFtpMessageReceiver.postProcess(EEFtpMessageReceiver.java:61)
    at org.mule.transport.ftp.FtpMessageReceiver$FtpWork.run(FtpMessageReceiver.java:312)
    at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
    at org.mule.work.WorkerContext.run(WorkerContext.java:286)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
ERROR 2014-08-03 21:00:57,138 [[tests].FTP.receiver.01] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
java.io.IOException: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
    at com.mulesoft.mule.transport.ftp.EEFtpMessageReceiver.postProcess(EEFtpMessageReceiver.java:61)
    at org.mule.transport.ftp.FtpMessageReceiver$FtpWork.run(FtpMessageReceiver.java:312)
    at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
    at org.mule.work.WorkerContext.run(WorkerContext.java:286)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
ERROR 2014-08-03 21:00:58,064 [[tests].FTP.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
java.io.IOException: Failed to rename file mytest.csv to C:\Users\user\Desktop\outputmytest.csv. Ftp error: 553
    at com.mulesoft.mule.transport.ftp.EEFtpMessageReceiver.postProcess(EEFtpMessageReceiver.java:61)
    at org.mule.transport.ftp.FtpMessageReceiver$FtpWork.run(FtpMessageReceiver.java:312)
    at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
    at org.mule.work.WorkerContext.run(WorkerContext.java:286)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
ERROR 2014-08-03 21:00:58,491 [[tests].dbFlow1.stage1.03] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Duplicate entry '546565' for key 'PRIMARY' (com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException). Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Duplicate entry '546565' for key 'PRIMARY' (com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException)
  sun.reflect.NativeConstructorAccessorImpl:-2 (null)
2. Duplicate entry '546565' for key 'PRIMARY' (com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.db.internal.processor.AbstractDbMessageProcessor:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '546565' for key 'PRIMARY'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

mytest.csv 的内容是这样的:(DB 相同的列,serialnumber 是主键)

date|serialnumber|gender|fullname|email|mobilenumber|address
03-07-2014|546565|m|your name|my@mail.com|219239|my address

我尝试使用#[message.inboundProperties.originalFilename]outputPattern="#[header:originalFilename]"。也许这些是错误的,但无论如何,Mule 一直显示相同的错误,没有任何变化!

关键是将文件从FTP移动到本地PC,然后将其插入DB然后发送电子邮件。 (两条路一起)。 任何帮助将不胜感激!

【问题讨论】:

    标签: mule mule-studio mule-el


    【解决方案1】:

    我开始发生类似的事情,我做了一个在 Studio 和 Standalone 3.50 中运行良好的项目,当我将相同的 .zip 部署文件移动到 3.51 时,它开始从 file:inbound-endpoint 的 @987654323 中提取文件@(我的已处理/归档目录)。

    在文件中获得锁:

    \\fsvr\vol2\DCH_ESB_Test\LMS\In2\Processed\LMS_20140821_112625_250.dat 
    

    在文件中获得锁:

    \\fsvr\vol2\DCH_ESB_Test\LMS\In2\Processed\LMS_20140821_112625_265.dat 
    

    它应该从以下位置拉取文件:

    \\fsvr\vol2\DCH_ESB_Test\LMS\In2
    

    而是将它们从以下位置拉出:

    \\fsvr\vol2\DCH_ESB_Test\LMS\In2\Processed 
    

    所以我的应用程序也开始通过我的档案通过我的每日确认电子邮件向我发送垃圾邮件。奇怪的是,在 3.51 上行为不端的同一个 zip 文件在 3.50 上也能正常工作。
    当然,在将其发布到野外之前,Mulesoft 会发现这一点。我唯一能想到的就是我也在流程结束时使用了一个 FTP 组件。不知道,但我确实知道将其恢复到 3.50 会使其正常运行。

    【讨论】:

      【解决方案2】:

      您没有显示您在 moveToDirectory 中唱出的值,但是,从例外情况来看,您似乎正试图移动到本地目录,这将是一个错误。

      moveToDirectory 的重点是将文件移动到远程目录,而不是本地目录。

      如果您想要从 FTP 下载的文件的本地副本,只需使用 file:outbound-endpoint 将其写入您想要的任何本地目录。

      【讨论】:

      • 好的。厉害了+1!但是如何将文件与其他组件一起使用? &lt;all&gt;&lt;processor-chain&gt;&lt;/all&gt; 已弃用。另外,当我尝试使用出站文件时,文件被移动为 .dat 而不是像原始文件那样的 .csv 文件。是否有任何配置要添加到 file:outbound 端点?提前致谢!
      • 您不需要全部:您应该能够将file:outbound-endpoint 直接放入您的流程中。是的,您可以控制写入文件的名称。请参阅用户指南中的outputPatternmulesoft.org/documentation/display/current/…
      • 好吧,似乎它正在工作,但它并没有停止:'(Mule 一直在做同样的事情,直到我手动停止它!我收到了 33 封电子邮件:3 并且数据库表即将已满 :D 文件名太长(我现在不能删除文件 :O)。请问如何告诉 Mule 只执行一次该过程?!
      • 这没有意义:moveToDirectory 配置正确吗?您是否看到文件从拾取目录移动到 moveTo 目录?
      • 不,我已删除 moveToDirectory,因为我希望将文件移动到本地 PC。我添加了:&lt;file:outbound-endpoint path="C:\Users\User\Desktop\output" outputPattern="#[message.inboundProperties['originalFilename']].csv" doc:name="File"/&gt; 我在FTP:inbound-endpoint 之后添加了它,文件从 ftp 移动到本地 PC(但名称为无穷大),数据插入 DB(无穷大记录),我正在接收电子邮件(无穷大电子邮件):'(
      猜你喜欢
      • 2016-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多