在Spring Integration中处理Null消息

时间:2013-06-20 10:41:23

标签: spring-integration

我正在使用spring integration(<int-ftp:outbound-gateway >)从ftp服务器检索文件,

首先,如果远程目录中没有文件,我无法继续该程序,我可以解决这个问题,将default-reply-timeout="100"添加到<int:gateway>,添加后我得到零点异常导致构建失败。

这是我的完整配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
       xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp
        http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
        http://www.springframework.org/schema/integration
        http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <context:property-placeholder location="classpath:host.properties"/>

    <int:gateway id="gw" service-interface="com.util.ToFtpFlowGateway"
                 default-request-channel="inbound" default-reply-timeout="100"/>

    <bean id="downloadProcessBean" class="com.util.FTPDownloadInterceptor">
        <property name="fileType" value="txt"/>
        <property name="sourceType" value="ftp"/>
        <property name="destinationName" value="destinationName"/>
        <property name="destinationQueName" value="destinationQueName"/>
        <property name="sourceAddressDetails" value="sourceAddressDetails"/>
        <property name="sourceName" value="sourceName"/>
    </bean>

    <bean id="ftpSessionFactory"
          class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="${local.host}"/>
        <property name="port" value="${local.availableServerPort}"/>
        <property name="username" value="${local.userid}"/>
        <property name="password" value="${local.user.password}"/>
    </bean>

    <int-ftp:outbound-gateway id="gatewayLS" cache-sessions="false"
                              session-factory="ftpSessionFactory"
                              request-channel="inbound"
                              command="ls"
                              command-options=""
                              expression="payload"
                              reply-channel="toSplitter" />

    <int:channel id="toSplitter">
        <int:interceptors>
            <int:wire-tap channel="logger"/>
        </int:interceptors>
    </int:channel>

    <int:logging-channel-adapter id="logger" log-full-message="true" />

    <int:splitter id="splitter" input-channel="toSplitter" output-channel="toGet"/>

    <int-ftp:outbound-gateway id="gatewayGET" cache-sessions="false"
                              local-directory="/home/udeshika/project/sxpmsg-distributer/req/local/download"
                              session-factory="ftpSessionFactory"
                              request-channel="toGet"
                              reply-channel="toRemoveChannel"
                              command="get"
                              command-options="-P"
                              expression="payload.remoteDirectory + '/' + payload.filename" reply-timeout="10"/>

    <int-ftp:outbound-gateway id="gatewayRM"
                              session-factory="ftpSessionFactory" cache-sessions="false"
                              expression="payload.remoteDirectory + '/'+ payload.filename"
                              request-channel="toRemoveChannel"
                              command="rm"
                              reply-channel="aggregateResultsChannel"
                              auto-create-local-directory="true"
                              reply-timeout="10"

            />
    <!--<bean id="fileDownloadIntecepter" class="shipxpress.util.FTPDownloadInterceptor"/>-->
    <int:channel id="toRemoveChannel">
        <int:interceptors>
            <int:wire-tap channel="logger2"/>
            <!--<int:ref bean="fileDownloadIntecepter" />-->
        </int:interceptors>
    </int:channel>

    <bean class="org.springframework.integration.file.FileReadingMessageSource"
          p:directory="${download.directory}"/>

    <int:logging-channel-adapter id="logger2"  log-full-message="true" />

    <int-ftp:outbound-gateway id="gatewayRM"
                              session-factory="ftpSessionFactory" cache-sessions="false"
                              expression="headers['file_remoteDirectory'] + '/' + headers['file_remoteFile']"
                              request-channel="toRemoveChannel"
                              command="rm"
                              reply-channel="aggregateResultsChannel"/>

    <int:aggregator input-channel="aggregateResultsChannel"/>

</beans>

java代码

 rmResults = toFtpFlow.lsGetAndRmFiles("testftp");
            if(null == rmResults)[
                LOGGER.info("Null returned");
            }

错误消息

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.200s
[INFO] Finished at: Thu Jun 20 15:48:43 IST 2013
[INFO] Final Memory: 15M/84M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:java (default) on project ftp: An exception occured while executing the Java class. null: InvocationTargetException: message must not be null -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

0 个答案:

没有答案