Added namespace support for configuring an endpoint's ErrorHandler strategy. For example, the "error-handler" attribute can be provided on the <service-activator/> element with a bean name reference to any implementation of the ErrorHandler interface (INT-178).

This commit is contained in:
Mark Fisher
2008-08-18 20:43:38 +00:00
parent 0ec6cd61d9
commit 58c768541a
6 changed files with 23 additions and 7 deletions

View File

@@ -104,4 +104,16 @@ public class EndpointParserTests {
endpoint.send(message);
}
@Test
public void testEndpointWithErrorHandler() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointWithErrorHandler.xml", this.getClass());
MessageChannel channel = (MessageChannel) context.getBean("channel");
TestErrorHandler errorHandler = (TestErrorHandler) context.getBean("errorHandler");
assertNull(errorHandler.getLastError());
channel.send(new StringMessage("test"));
assertNotNull(errorHandler.getLastError());
assertEquals("intentional test failure", errorHandler.getLastError().getMessage());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.

View File

@@ -6,15 +6,15 @@
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
<message-bus/>
<channel id="testChannel"/>
<direct-channel id="channel"/>
<service-activator id="endpoint" input-channel="testChannel" ref="testHandler" error-handler="errorHandler"/>
<service-activator id="endpoint" input-channel="channel" ref="handler" error-handler="errorHandler"/>
<beans:bean id="testHandler" class="org.springframework.integration.config.ExceptionThrowingTestHandler"/>
<beans:bean id="handler" class="org.springframework.integration.config.ExceptionThrowingTestHandler"/>
<beans:bean id="errorHandler" class="org.springframework.integration.config.TestErrorHandler"/>
</beans:beans>