INT-1708, INT-1709 added initial support for 'error-channel' to inbound-channel-adapters
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:task="http://www.springframework.org/schema/task">
|
||||
|
||||
<int:inbound-channel-adapter id="withErrorHeader" expression="5/0" channel="serviceChannel" auto-startup="false">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
<int:header name="errorChannel" value="eChannel"/>
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:inbound-channel-adapter id="withErrorChannel" expression="5/0"
|
||||
channel="serviceChannel" auto-startup="false" error-channel="eChannel">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:channel id="serviceChannel"/>
|
||||
|
||||
<int:channel id="eChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
</beans>
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.config.xml;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class PollerWithErrorChannel {
|
||||
|
||||
@Test
|
||||
public void testWithErrorChannelAsHeader() throws Exception{
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
|
||||
SourcePollingChannelAdapter adapter = ac.getBean("withErrorHeader", SourcePollingChannelAdapter.class);
|
||||
adapter.start();
|
||||
PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class);
|
||||
assertNotNull(errorChannel.receive(100000));
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithErrorChannel() throws Exception{
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
|
||||
SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannel", SourcePollingChannelAdapter.class);
|
||||
adapter.start();
|
||||
PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class);
|
||||
assertNotNull(errorChannel.receive(100000));
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
public static class SampleService{
|
||||
public String withSuccess(){
|
||||
return "hello";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user