MULE ESB 导入 CSV,如果没有 CSV 列数据(空白数据),则出错

MULE ESB Import CSV, if no CSV column data (blank data) , errors out

我正在使用此 MULE ESB 流程将 CSV 文件导入 MYSQL 数据库。我已经确定,如果有一个 CSV 列是 'empty',则 MULE 流将出错并出现以下错误:

Message               : Execution of the expression "message.payload[4]" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String[]

这是导致错误的 CSV:

 Gone,2691,,13-Jul,8/10/2010

但是,如果我将 CSV 文件更改为此(注意添加了白色 space),这将按预期工作。

Gone,2691, ,13-Jul,8/10/2010

我是否需要 运行 我的 CSV 中的额外步骤(在 Mule 处理之前)将所有 'blank' 值更改为 NULL,或者 Mule 中是否有方法导入这些空白值在 CSV 文件中?

这是我正在使用的配置文件:

<context:property-placeholder location="classpath:mysql.properties,classpath:smtp.properties" />
<configuration doc:name="Configuration"> 
    <expression-language autoResolveVariables="true"> 
        <import class="org.mule.util.StringUtils"></import>  
    </expression-language>  
</configuration>

<db:mysql-config name="MySQL_Configuration" host="${mysql.host}" port="${mysql.port}" user="${mysql.user}" database="${mysql.database}" password="${mysql.password}" doc:name="MySQL Configuration"/>

<flow name="ImportCSVFileToDatabase" > 
    <file:inbound-endpoint path="\192.168.10.6\pfw" pollingFrequency="5000" doc:name="Source" responseTimeout="10000" moveToDirectory="C:\Users\IEUser\Desktop\Post Processed">
        <file:filename-regex-filter pattern="Tractor_Status.csv" caseSensitive="true"/>
    </file:inbound-endpoint>  
    <object-to-string-transformer doc:name="Object to String"></object-to-string-transformer>  
    <splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter"></splitter>  
    <expression-transformer expression="#[StringUtils.split(message.payload, ',')]" doc:name="Expression" ></expression-transformer> 
            <db:insert config-ref="MySQL_Configuration" doc:name="Database">
        <db:parameterized-query><![CDATA[INSERT INTO Tractor_Sheet(
 Status,
 Build_Number,
 Ship_Date,
 Production_Completion_Date
 ) VALUES (
 #[message.payload[0]],
 #[message.payload[1]],
 #[message.payload[2]],
 #[message.payload[4]]
 )]]></db:parameterized-query>
            </db:insert>    
  </flow>

如果以后有人偶然发现这个,我添加了一个额外的表达式

#[StringUtils.replace(message.payload, ",,", ", ,")]