INT-1745 added support for error-channel to in-the-chain gateways
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.5.0.201010221000-RELEASE]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.5.2.201101121000-SR1]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/java/org/springframework/integration/gateway/GatewayInterfaceTest-context.xml</config>
|
||||
<config>src/test/java/org/springframework/integration/gateway/InnerGatewayWithChainTests-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
</configSets>
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GatewayParser extends AbstractSimpleBeanDefinitionParser {
|
||||
};
|
||||
|
||||
private static String[] innerAttributes = new String[] {
|
||||
"request-channel", "reply-channel", "request-timeout", "reply-timeout"
|
||||
"request-channel", "reply-channel", "request-timeout", "reply-timeout", "error-channel"
|
||||
};
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ public class GatewayParser extends AbstractSimpleBeanDefinitionParser {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-channel", "defaultRequestChannel");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel", "defaultReplyChannel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout", "defaultRequestTimeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "defaultReplyTimeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "defaultReplyTimeout");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-channel");
|
||||
}
|
||||
|
||||
private void postProcessGateway(BeanDefinitionBuilder builder, Element element) {
|
||||
|
||||
@@ -660,6 +660,15 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="error-channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Identifies channel that error messages will be sent to if a failure occurs in this
|
||||
adapter's invocation. To completely suppress Exceptions, provide a
|
||||
reference to the "nullChannel" here.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:element name="inbound-channel-adapter">
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<int:channel id="errorChannelA"/>
|
||||
|
||||
<int:service-activator input-channel="errorChannelA" expression="'ERROR from errorChannelA'"/>
|
||||
|
||||
<int:channel id="errorChannelB"/>
|
||||
|
||||
<int:service-activator input-channel="errorChannelB" expression="'ERROR from errorChannelB'"/>
|
||||
|
||||
|
||||
<int:gateway id="testGateway"
|
||||
service-interface="org.springframework.integration.gateway.InnerGatewayWithChainTests.TestGateway"
|
||||
default-request-channel="requestChannelA"
|
||||
error-channel="errorChannelA"/>
|
||||
|
||||
<int:chain input-channel="requestChannelA">
|
||||
<int:service-activator expression="1/(payload-5)"/>
|
||||
<int:gateway request-channel="requestChannelB" error-channel="errorChannelB"/>
|
||||
</int:chain>
|
||||
|
||||
<int:service-activator input-channel="requestChannelB" expression="10/payload"/>
|
||||
</beans>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class InnerGatewayWithChainTests {
|
||||
|
||||
@Autowired
|
||||
private TestGateway testGateway;
|
||||
|
||||
@Test
|
||||
public void testExceptionHandledByMainGateway(){
|
||||
String reply = testGateway.echo(5);
|
||||
assertEquals("ERROR from errorChannelA", reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionHandledByInnerGateway(){
|
||||
String reply = testGateway.echo(0);
|
||||
assertEquals("ERROR from errorChannelB", reply);
|
||||
}
|
||||
|
||||
public static interface TestGateway{
|
||||
public String echo(int value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user