Remove MessageChannelItemWriter in favour of using a MessagingGateway (integration test included as demo)

This commit is contained in:
dsyer
2009-03-06 07:32:20 +00:00
parent ad1ebb61ef
commit f7a89aa85f
19 changed files with 591 additions and 631 deletions

View File

@@ -11,7 +11,6 @@
<config>src/test/resources/simple-job-launcher-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/chunk/ChunkMessageItemWriterIntegrationTests-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/launch/JobLaunchingMessageHandlerIntegrationTests-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/item/MessageChannelItemWriterIntegrationTests-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/job/MessageOrientedStepIntegrationTests-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/file/ResourceSplitterIntegrationTests-context.xml</config>
<config>src/test/resources/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests-context.xml</config>

View File

@@ -9,6 +9,9 @@
<version>2.0.0.CI-SNAPSHOT</version>
<relativePath>../spring-batch-parent</relativePath>
</parent>
<properties>
<spring.integration.version>1.0.2.BUILD-SNAPSHOT</spring.integration.version>
</properties>
<profiles>
<profile>
<activation>
@@ -133,7 +136,4 @@
</artifactId>
</dependency>
</dependencies>
<properties>
<spring.integration.version>1.0.1.RELEASE</spring.integration.version>
</properties>
</project>

View File

@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.List;
import java.util.Properties;
import org.springframework.batch.core.Job;
@@ -33,9 +34,9 @@ import org.springframework.batch.core.job.SimpleJob;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.item.SimpleStepFactoryBean;
import org.springframework.batch.integration.item.MessageChannelItemWriter;
import org.springframework.batch.integration.launch.JobLaunchingMessageHandler;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.xml.StaxEventItemReader;
import org.springframework.beans.factory.BeanNameAware;
@@ -47,6 +48,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
@@ -56,8 +58,8 @@ import org.springframework.util.Assert;
* ensure that failures propagate up to the step and fail the job execution.
* Normally this job will be used in conjunction with a
* {@link JobLaunchingMessageHandler} and a
* {@link ResourcePayloadAsJobParameterStrategy}, so that the user can just
* send a message to a request channel listing the files to be processed, and
* {@link ResourcePayloadAsJobParameterStrategy}, so that the user can just send
* a message to a request channel listing the files to be processed, and
* everything else just happens by magic. After a failure the job will be
* restarted just by sending it the same message.
*
@@ -79,7 +81,9 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
/*
* (non-Javadoc)
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
* @see
* org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang
* .String)
*/
public void setBeanName(String name) {
this.name = name;
@@ -91,8 +95,7 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
* case there is no need to set the resource property as it will be set by
* this factory.
*
* @param itemReader
* the itemReader to set
* @param itemReader the itemReader to set
*/
@Required
public void setItemReader(ItemReader<? extends T> itemReader) {
@@ -103,8 +106,7 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
* Public setter for the channel. Each item from the item reader will be
* sent to this channel.
*
* @param channel
* the channel to set
* @param channel the channel to set
*/
@Required
public void setChannel(MessageChannel channel) {
@@ -114,8 +116,7 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
/**
* Public setter for the {@link JobRepository}.
*
* @param jobRepository
* the job repository to set
* @param jobRepository the job repository to set
*/
@Required
public void setJobRepository(JobRepository jobRepository) {
@@ -125,8 +126,7 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
/**
* Public setter for the {@link PlatformTransactionManager}.
*
* @param transactionManager
* the transaction manager to set
* @param transactionManager the transaction manager to set
*/
@Required
public void setTransactionManager(PlatformTransactionManager transactionManager) {
@@ -160,8 +160,7 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
Assert.notNull(channel, "A channel must be provided");
Assert.state(channel instanceof DirectChannel,
"The channel must be a DirectChannel (otherwise failures can not be recovered from)");
MessageChannelItemWriter<? super T> itemWriter = new MessageChannelItemWriter<T>();
itemWriter.setChannel(channel);
MessageChannelItemWriter<? super T> itemWriter = new MessageChannelItemWriter<T>(channel);
stepFactory.setItemWriter(itemWriter);
Assert.notNull(transactionManager, "A transaction manager must be provided");
@@ -331,8 +330,8 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
* translate {@link JobParameters} into {@link Properties}. Defaults to
* a {@link DefaultJobParametersConverter}.
*
* @param jobParametersConverter
* the {@link JobParametersConverter} to set
* @param jobParametersConverter the {@link JobParametersConverter} to
* set
*/
public void setJobParametersFactory(JobParametersConverter jobParametersConverter) {
this.jobParametersConverter = jobParametersConverter;
@@ -370,4 +369,21 @@ public class FileToMessagesJobFactoryBean<T> implements FactoryBean, BeanNameAwa
delegate = resourceLoader.getResource(properties.getProperty(this.key));
}
}
private static class MessageChannelItemWriter<T> implements ItemWriter<T> {
private MessageChannel channel;
public MessageChannelItemWriter(MessageChannel channel) {
super();
this.channel = channel;
}
public void write(List<? extends T> items) throws Exception {
for (T item : items) {
channel.send(new GenericMessage<T>(item));
}
}
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright 2006-2007 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.batch.integration.item;
import java.util.List;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.GenericMessage;
/**
* @author Dave Syer
*
*/
public class MessageChannelItemWriter<T> implements ItemWriter<T> {
private MessageChannel channel;
/**
* Public setter for the channel.
* @param channel the channel to set
*/
@Required
public void setChannel(MessageChannel channel) {
this.channel = channel;
}
/*
* (non-Javadoc)
*
* @see org.springframework.batch.item.ItemWriter#write(java.lang.Object)
*/
public void write(List<? extends T> items) throws Exception {
for (T item : items) {
channel.send(new GenericMessage<T>(item));
}
}
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2006-2007 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.batch.integration.item;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.Message;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
*
*/
@ContextConfiguration()
@RunWith(SpringJUnit4ClassRunner.class)
public class MessageChannelItemWriterIntegrationTests {
@Autowired
@Qualifier("requests")
private PollableChannel channel;
@Autowired
private ItemWriter<String> itemWriter;
@Test
public void testSend() throws Exception {
itemWriter.write(Collections.singletonList("foo"));
Message<?> message = channel.receive(10);
assertNotNull(message);
assertEquals("foo", message.getPayload());
}
}

View File

@@ -1,106 +0,0 @@
/*
* Copyright 2006-2007 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.batch.integration.item;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collections;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.ThreadLocalChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.MessageHandler;
import org.springframework.util.ReflectionUtils;
/**
* @author Dave Syer
*
*/
public class MessageChannelItemWriterTests {
/**
* Test method for
* {@link MessageChannelItemWriter#setChannel(MessageChannel)} .
*/
@Test
public void testSetChannel() {
Method method = ReflectionUtils.findMethod(MessageChannelItemWriter.class, "setChannel",
new Class<?>[] { MessageChannel.class });
assertNotNull(method);
Annotation[] annotations = AnnotationUtils.getAnnotations(method);
assertEquals(1, annotations.length);
assertEquals(Required.class, annotations[0].annotationType());
}
@Test
public void testWrite() throws Exception {
ThreadLocalChannel receiver = new ThreadLocalChannel();
MessageChannelItemWriter<String> writer = new MessageChannelItemWriter<String>();
writer.setChannel(receiver);
writer.write(Collections.singletonList("foo"));
Message<?> message = receiver.receive(10);
assertNotNull(message);
assertEquals("foo", message.getPayload());
}
@Test
public void testWriteWithRollback() throws Exception {
DirectChannel channel = new DirectChannel();
channel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
throw new RuntimeException("Planned failure");
}
});
MessageChannelItemWriter<String> writer = new MessageChannelItemWriter<String>();
writer.setChannel(channel);
try {
writer.write(Collections.singletonList("foo"));
fail("Expected RuntimeException");
}
catch (RuntimeException e) {
assertEquals("Planned failure", e.getMessage());
}
}
@Test
public void testWriteWithRollbackOnEndpoint() throws Exception {
DirectChannel channel = new DirectChannel();
channel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
throw new RuntimeException("Planned failure");
}
});
MessageChannelItemWriter<String> writer = new MessageChannelItemWriter<String>();
writer.setChannel(channel);
try {
writer.write(Collections.singletonList("foo"));
fail("Expected RuntimeException");
}
catch (RuntimeException e) {
// INT-377: this assertion fails because the exception is wrapped
// too tightly
assertEquals("Planned failure", e.getMessage());
}
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright 2006-2007 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.batch.integration.item;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.annotation.Splitter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Test case showing the use of a MessagingGateway to provide an ItemWriter or
* ItemProcessor to Spring Batch that is hooked directly into a Sprng
* Integration MessageChannel.
*
* @author Dave Syer
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class MessagingGatewayIntegrationTests {
@Autowired
private ItemProcessor<String, String> processor;
@Autowired
private ItemWriter<String> writer;
/**
* Just for the sake of being able to make assertions.
*/
@Autowired
private EndService service;
/**
* Just for the sake of being able to make assertions.
*/
@Autowired
private SplitService splitter;
@Test
public void testProcessor() throws Exception {
String result = processor.process("foo");
assertEquals("foo: 0: 1", result);
assertNull(processor.process("filter"));
}
@Test
public void testWriter() throws Exception {
writer.write(Arrays.asList("foo", "bar", "spam"));
assertEquals(3, splitter.count);
assertEquals(3, service.count);
}
/**
* This service is wrapped into an ItemProcessor and used to transform
* items. This is where the main business processing could take place in a
* real application. To suppress output the service activator can just
* return null (same as an ItemProcessor) but remember to set the reply
* timeout in the gateway.
*
* @author Dave Syer
*
*/
@MessageEndpoint
public static class Activator {
private int count;
@ServiceActivator
public String transform(String input) {
if (input.equals("filter")) {
return null;
}
return input + ": " + (count++);
}
}
/**
* The Splitter is wrapped into an ItemWriter and used to relay items to its
* output channel. This one is completely trivial, it just passes the items
* on as they are. More complex splitters might filter or enhance the items
* before passing them on.
*
* @author Dave Syer
*
*/
@MessageEndpoint
public static class SplitService {
// Just for assertions in the test case
private int count;
@Splitter
public List<String> split(List<String> input) {
count += input.size();
return input;
}
}
/**
* This is just used to trap the messages sent by the ItemWriter and make an
* assertion about them in the the test case. In a real application this
* would be the output stage and/or business processing.
*
* @author Dave Syer
*
*/
@MessageEndpoint
public static class EndService {
private int count;
@ServiceActivator
public void service(String input) {
count++;
return;
}
}
}

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<annotation-config/>
<channel id="jobs" />
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<annotation-config/>
<channel id="jobs" />
</beans:beans>

View File

@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<annotation-config/>
<channel id="smokein"/>
<channel id="smokeout">
<queue/>
</channel>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<annotation-config/>
<channel id="smokein"/>
<channel id="smokeout">
<queue/>
</channel>
</beans:beans>

View File

@@ -1,33 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<annotation-config/>
<channel id="requests" />
<channel id="replies">
<queue/>
</channel>
<beans:bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:annotation-driven />
<beans:bean id="chunkHandler" class="org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler">
<beans:property name="chunkProcessor">
<beans:bean class="org.springframework.batch.core.step.item.SimpleChunkProcessor">
<beans:property name="itemWriter">
<beans:bean class="org.springframework.batch.integration.chunk.TestItemWriter" />
</beans:property>
<beans:property name="itemProcessor">
<beans:bean class="org.springframework.batch.item.support.PassthroughItemProcessor" />
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<service-activator input-channel="requests" output-channel="replies" ref="chunkHandler" />
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
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-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<annotation-config/>
<channel id="requests" />
<channel id="replies">
<queue/>
</channel>
<beans:bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:annotation-driven />
<beans:bean id="chunkHandler" class="org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler">
<beans:property name="chunkProcessor">
<beans:bean class="org.springframework.batch.core.step.item.SimpleChunkProcessor">
<beans:property name="itemWriter">
<beans:bean class="org.springframework.batch.integration.chunk.TestItemWriter" />
</beans:property>
<beans:property name="itemProcessor">
<beans:bean class="org.springframework.batch.item.support.PassThroughItemProcessor" />
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<service-activator input-channel="requests" output-channel="replies" ref="chunkHandler" />
</beans:beans>

View File

@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config/>
<integration:channel id="resources" />
<integration:channel id="requests">
<integration:queue/>
</integration:channel>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config/>
<integration:channel id="resources" />
<integration:channel id="requests">
<integration:queue/>
</integration:channel>
</beans>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config/>
<integration:channel id="requests">
<integration:queue/>
</integration:channel>
<bean id="itemWriter" class="org.springframework.batch.integration.item.MessageChannelItemWriter">
<property name="channel" ref="requests"/>
</bean>
</beans>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="transforms" />
<integration:channel id="replies" />
<integration:gateway service-interface="org.springframework.batch.item.ItemProcessor" id="processor" default-reply-timeout="10"
default-request-timeout="100" default-request-channel="requests" default-reply-channel="replies" />
<integration:service-activator input-channel="requests" output-channel="transforms" ref="activator" />
<integration:service-activator input-channel="transforms" output-channel="replies" ref="activator" />
<bean id="activator" class="org.springframework.batch.integration.item.MessagingGatewayIntegrationTests$Activator" />
<integration:gateway service-interface="org.springframework.batch.item.ItemWriter" id="writer"
default-request-timeout="100" default-request-channel="inputs" />
<integration:channel id="inputs" />
<integration:channel id="outputs" />
<integration:splitter input-channel="inputs" output-channel="outputs" ref="splitter" />
<integration:service-activator input-channel="outputs" ref="service" />
<bean id="splitter" class="org.springframework.batch.integration.item.MessagingGatewayIntegrationTests$SplitService" />
<bean id="service" class="org.springframework.batch.integration.item.MessagingGatewayIntegrationTests$EndService" />
</beans>

View File

@@ -1,39 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="classpath:/simple-job-launcher-context.xml" />
<integration:annotation-config/>
<integration:channel id="requests" />
<integration:channel id="replies">
<integration:queue/>
</integration:channel>
<bean id="job" parent="simpleJob">
<property name="steps">
<bean id="stepController" class="org.springframework.batch.integration.job.MessageOrientedStep">
<property name="outputChannel" ref="requests" />
<property name="inputChannel" ref="replies" />
<property name="jobRepository" ref="jobRepository" />
</bean>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="step" class="org.springframework.batch.integration.job.StepExecutionMessageHandler">
<property name="step">
<bean parent="taskletStep">
<property name="tasklet">
<bean class="org.springframework.batch.integration.job.TestTasklet" />
</property>
</bean>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
<integration:service-activator ref="step" input-channel="requests" output-channel="replies" />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="classpath:/simple-job-launcher-context.xml" />
<integration:annotation-config/>
<integration:channel id="requests" />
<integration:channel id="replies">
<integration:queue/>
</integration:channel>
<bean id="job" parent="simpleJob">
<property name="steps">
<bean id="stepController" class="org.springframework.batch.integration.job.MessageOrientedStep">
<property name="outputChannel" ref="requests" />
<property name="inputChannel" ref="replies" />
<property name="jobRepository" ref="jobRepository" />
</bean>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="step" class="org.springframework.batch.integration.job.StepExecutionMessageHandler">
<property name="step">
<bean parent="taskletStep">
<property name="tasklet">
<bean class="org.springframework.batch.integration.job.TestTasklet" />
</property>
</bean>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
<integration:service-activator ref="step" input-channel="requests" output-channel="replies" />
</beans>

View File

@@ -1,32 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="classpath:simple-job-launcher-context.xml" />
<integration:annotation-config/>
<integration:channel id="requests" />
<integration:channel id="response">
<integration:queue/>
</integration:channel>
<integration:service-activator input-channel="requests" ref="jobLaunchingHandler" method="launch" />
<bean id="jobLaunchingHandler" class="org.springframework.batch.integration.launch.JobLaunchingMessageHandler">
<constructor-arg ref="jobLauncher" />
</bean>
<bean id="testJob" parent="simpleJob">
<property name="steps" ref="step" />
</bean>
<bean id="step" parent="taskletStep">
<property name="tasklet">
<bean class="org.springframework.batch.integration.job.TestTasklet" />
</property>
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="classpath:simple-job-launcher-context.xml" />
<integration:annotation-config/>
<integration:channel id="requests" />
<integration:channel id="response">
<integration:queue/>
</integration:channel>
<integration:service-activator input-channel="requests" ref="jobLaunchingHandler" method="launch" />
<bean id="jobLaunchingHandler" class="org.springframework.batch.integration.launch.JobLaunchingMessageHandler">
<constructor-arg ref="jobLauncher" />
</bean>
<bean id="testJob" parent="simpleJob">
<property name="steps" ref="step" />
</bean>
<bean id="step" parent="taskletStep">
<property name="tasklet">
<bean class="org.springframework.batch.integration.job.TestTasklet" />
</property>
</bean>
</beans>

View File

@@ -1,53 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:service-activator ref="testCase" input-channel="requests" output-channel="replies" method="process"/>
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100"/>
<integration:advice-chain>
<ref bean="txAdvice"/>
<ref bean="repeatAdvice"/>
</integration:advice-chain>
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RepeatTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:advice id="txAdvice">
<tx:attributes><tx:method name="*"/></tx:attributes>
</tx:advice>
<bean id="repeatAdvice" class="org.springframework.batch.repeat.interceptor.RepeatOperationsInterceptor">
<property name="repeatOperations">
<bean class="org.springframework.batch.repeat.support.RepeatTemplate">
<property name="completionPolicy">
<bean class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
<property name="chunkSize" value="2" />
</bean>
</property>
</bean>
</property>
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:service-activator ref="testCase" input-channel="requests" output-channel="replies" method="process"/>
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100"/>
<integration:advice-chain>
<ref bean="txAdvice"/>
<ref bean="repeatAdvice"/>
</integration:advice-chain>
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RepeatTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:advice id="txAdvice">
<tx:attributes><tx:method name="*"/></tx:attributes>
</tx:advice>
<bean id="repeatAdvice" class="org.springframework.batch.repeat.interceptor.RepeatOperationsInterceptor">
<property name="repeatOperations">
<bean class="org.springframework.batch.repeat.support.RepeatTemplate">
<property name="completionPolicy">
<bean class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
<property name="chunkSize" value="2" />
</bean>
</property>
</bean>
</property>
</bean>
</beans>

View File

@@ -1,90 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<!--
TODO: the initial delay is a hack - it usually prevents the poller
from picking up data in the list before it is cleared, but one day
100ms will not be enough... (see INT-536)
-->
<integration:interval-trigger interval="10"
initial-delay="100" />
<integration:advice-chain>
<ref bean="txAdvice" />
<ref bean="repeatAdvice" />
</integration:advice-chain>
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RetryRepeatTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<bean id="repeatAdvice"
class="org.springframework.batch.repeat.interceptor.RepeatOperationsInterceptor">
<property name="repeatOperations">
<bean class="org.springframework.batch.repeat.support.RepeatTemplate">
<property name="completionPolicy">
<bean
class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
<property name="chunkSize" value="2" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="service"
class="org.springframework.batch.integration.retry.SimpleService" />
<bean id="recoverer"
class="org.springframework.batch.integration.retry.SimpleRecoverer" />
<bean id="retryAdvice"
class="org.springframework.batch.retry.interceptor.StatefulRetryOperationsInterceptor">
<property name="retryOperations">
<bean class="org.springframework.batch.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="2" />
</bean>
</property>
</bean>
</property>
<property name="recoverer" ref="recoverer" />
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="retryAdvice"
pointcut="execution(* org.springframework.batch.integration.retry.Service+.process(..))" />
</aop:config>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<!--
TODO: the initial delay is a hack - it usually prevents the poller
from picking up data in the list before it is cleared, but one day
100ms will not be enough... (see INT-536)
-->
<integration:interval-trigger interval="10"
initial-delay="100" />
<integration:advice-chain>
<ref bean="txAdvice" />
<ref bean="repeatAdvice" />
</integration:advice-chain>
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RetryRepeatTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<bean id="repeatAdvice"
class="org.springframework.batch.repeat.interceptor.RepeatOperationsInterceptor">
<property name="repeatOperations">
<bean class="org.springframework.batch.repeat.support.RepeatTemplate">
<property name="completionPolicy">
<bean
class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
<property name="chunkSize" value="2" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="service"
class="org.springframework.batch.integration.retry.SimpleService" />
<bean id="recoverer"
class="org.springframework.batch.integration.retry.SimpleRecoverer" />
<bean id="retryAdvice"
class="org.springframework.batch.retry.interceptor.StatefulRetryOperationsInterceptor">
<property name="retryOperations">
<bean class="org.springframework.batch.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="2" />
</bean>
</property>
</bean>
</property>
<property name="recoverer" ref="recoverer" />
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="retryAdvice"
pointcut="execution(* org.springframework.batch.integration.retry.Service+.process(..))" />
</aop:config>
</beans>

View File

@@ -1,51 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100" />
<integration:transactional />
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RetryTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="service" class="org.springframework.batch.integration.retry.SimpleService" />
<bean id="recoverer" class="org.springframework.batch.integration.retry.SimpleRecoverer" />
<bean id="retryAdvice" class="org.springframework.batch.retry.interceptor.StatefulRetryOperationsInterceptor">
<property name="retryOperations">
<bean class="org.springframework.batch.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="2" />
</bean>
</property>
</bean>
</property>
<property name="recoverer" ref="recoverer" />
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="retryAdvice" pointcut="execution(* org.springframework.batch.integration.retry.Service+.process(..))" />
</aop:config>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100" />
<integration:transactional />
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.RetryTransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="service" class="org.springframework.batch.integration.retry.SimpleService" />
<bean id="recoverer" class="org.springframework.batch.integration.retry.SimpleRecoverer" />
<bean id="retryAdvice" class="org.springframework.batch.retry.interceptor.StatefulRetryOperationsInterceptor">
<property name="retryOperations">
<bean class="org.springframework.batch.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="2" />
</bean>
</property>
</bean>
</property>
<property name="recoverer" ref="recoverer" />
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="retryAdvice" pointcut="execution(* org.springframework.batch.integration.retry.Service+.process(..))" />
</aop:config>
</beans>

View File

@@ -1,36 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100"/>
<integration:transactional />
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.TransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<integration:annotation-config />
<integration:channel id="requests" />
<integration:channel id="replies" />
<integration:inbound-channel-adapter
ref="testCase" method="input" channel="requests">
<integration:poller max-messages-per-poll="1">
<integration:interval-trigger interval="10" initial-delay="100"/>
<integration:transactional />
</integration:poller>
</integration:inbound-channel-adapter>
<integration:outbound-channel-adapter
ref="testCase" method="output" channel="replies" />
<bean id="testCase"
class="org.springframework.batch.integration.retry.TransactionalPollingIntegrationTests" />
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
</beans>