如何使用request-handler-advice-chain和ExpressionEvaluatingRequestHandlerAdvice?

时间:2017-06-10 08:12:44

标签: java spring exception jdbc spring-integration

是xml.ftl:

<integration:channel id="${provider_name}Channel"/>
    <integration:header-enricher input-channel="${provider_name}Channel"
                                 output-channel="${provider_name}reformedNumberChannel">
        <integration:header name="reformedNumber"
                            expression="T(com.tosan.chapar.core.helper.PhoneNumberHelper).removeInitialPlus(headers[recipient])"/>
        <integration:header name="body" expression="payload"/>
    </integration:header-enricher>

    <jdbc:outbound-gateway request-channel="${provider_name}reformedNumberChannel"
                           data-source="${provider_name}DataSource"
                           update="insert into `outgoing_message` (`from_mobile_number`, `dest_mobile_number`, `message_body`, `due_date`, `creation_date`, `udh`, `source_port`, `dest_port`, `dcs`, `priority`, `status`)
                                          values ('${sms_number}', :headers[reformedNumber], :payload, now(), now(), '', :headers[port], :headers[port], :headers[dcs], :headers[priority], null);"
                           reply-channel="${provider_name}OutputChannel">
        <jdbc:request-handler-advice-chain>
            <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
                <property name="trapException" value="true"/>
                <property name="onFailureExpression" value="payload"/>
                <property name="failureChannel" value="failures"/>
            </bean>

        </jdbc:request-handler-advice-chain>
    </jdbc:outbound-gateway>

    <integration:transformer input-channel="failures" output-channel="stdout"
                     expression="'Removal of '" ></integration:transformer>
    <integration:channel id="stdout"/>
    <integration:service-activator input-channel="stdout"
                                   ref="messageLogServiceWrapperImpl" method="log"/>

    <integration:channel id="${provider_name}MessageLogChannel"/>

我想获取抛出jdbc的MessageHandlingException,使用上面的xml文件我得到了这个异常:

Exception in thread "main" `org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice#6acc3b9b' defined in Byte array resource [resource loaded from byte array]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.String] to required type [org.springframework.messaging.MessageChannel] for property 'failureChannel'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.messaging.MessageChannel] for property 'failureChannel': no matching editors or conversion strategy found`

如何设置failureChannel ??????

1 个答案:

答案 0 :(得分:2)

你必须使用

<ion-item>
    <ion-label floating>Tagebucheintrag</ion-label>
    <!-- <ion-input type="text" [(ngModel)]="description" id="description"></ion-input> -->
    <ion-textarea name="description" cols="40" rows="5" id="description"></ion-textarea>
</ion-item>

相反。我的意思是 <property name="failureChannel" ref="failures"/> 用于bean引用,而不是ref。请参阅value XSD中的说明。