這是.xml.ftl文件:如何使用jdbc:outbound-gateway捕獲org.springframework.messaging.MessageHandlingException?
<?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:jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:integration="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<!-- remove initial + from number -->
<integration:channel id="${provider_name}Channel"/>
<integration:header-enricher input-channel="${provider_name}Channel"
output-channel="catchException">
<integration:header name="reformedNumber"
expression="T(com.tosan.chapar.core.helper.PhoneNumberHelper).removeInitialPlus(headers[recipient])"/>
<integration:header name="body" expression="payload"/>
</integration:header-enricher>
<!--to catch exception-->
<integration:channel id="catchException"/>
<integration:service-activator input-channel="catchException"
output-channel="${provider_name}reformedNumberChannel"
ref="providerExceptionHandller" method="catchProviderException"/>
<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的信道拋出 「org.springframework.messaging.MessageHandlingException」。我想將它作爲一個消息來處理它。我決定使用「ProviderExceptionHandller.class」並處理「catchProviderException()」方法中的異常。有可能的? 它是類代碼:
public class ProviderExceptionHandller {
public void catchProviderException() {
//// want to catch Exception here, How??????
}
}
我如何能趕上Spring集成異常??? 我不想使用方面? 我的方法是可能的?
**所有**異常的類型爲'Throwable'。你不能以這種方式使用服務激活器;您需要一個帶有錯誤通道的網關,但您應該顯示其餘配置,包括流程的開始,以便我們可以爲錯誤處理提供更好的建議。 –
@Gray Russell ...謝謝你...(:更新我的問題,你能幫我嗎? –