@@ -124,20 +124,7 @@ The `AmqpItemReader` and Writer were contributed by Chris Schaefer.
|
||||
It is modeled after the `JmsItemReader` / Writer implementations, which
|
||||
are popular models for remote chunking. It leverages the `AmqpTemplate`.
|
||||
|
||||
This example requires the env to have a copy of rabbitmq installed
|
||||
and running. The standard dashboard can be used to see the traffic
|
||||
from the `MessageProducer` to the `AmqpItemWriter`. Make sure you
|
||||
launch the `MessageProducer` before launching the test.
|
||||
|
||||
You can run the sample from the command line as following:
|
||||
|
||||
```
|
||||
cd spring-batch-samples
|
||||
# Launch the test using the XML configuration
|
||||
../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithXmlConfig test
|
||||
# Launch the test using the Java configuration
|
||||
../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithJavaConfig test
|
||||
```
|
||||
[Amqp Job Sample](./src/main/java/org/springframework/batch/sample/rabbitmq/README.md)
|
||||
|
||||
### BeanWrapperMapper Sample
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.amqp;
|
||||
package org.springframework.batch.sample.rabbitmq;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.amqp.builder.AmqpItemReaderBuilder;
|
||||
import org.springframework.batch.item.amqp.builder.AmqpItemWriterBuilder;
|
||||
import org.springframework.batch.sample.rabbitmq.processor.MessageProcessor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
@@ -55,6 +56,7 @@ public class AmqpJobConfiguration {
|
||||
RabbitTemplate rabbitInputTemplate, RabbitTemplate rabbitOutputTemplate) {
|
||||
return new StepBuilder("step", jobRepository).<String, String>chunk(1, transactionManager)
|
||||
.reader(amqpItemReader(rabbitInputTemplate))
|
||||
.processor(new MessageProcessor())
|
||||
.writer(amqpItemWriter(rabbitOutputTemplate))
|
||||
.build();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# AMQP sample Job
|
||||
|
||||
## About
|
||||
|
||||
This sample shows the use of Spring Batch to write to an `AmqpItemWriter`.
|
||||
The `AmqpItemReader` and Writer were contributed by Chris Schaefer.
|
||||
It is modeled after the `JmsItemReader` / Writer implementations, which
|
||||
are popular models for remote chunking. It leverages the `AmqpTemplate`.
|
||||
|
||||
## Run the sample
|
||||
|
||||
This example requires the env to have a copy of rabbitmq installed
|
||||
and running. The standard dashboard can be used to see the traffic
|
||||
from the `MessageProducer` to the `AmqpItemWriter`. Make sure you
|
||||
launch the `MessageProducer` before launching the test.
|
||||
|
||||
You can run the sample from the command line as following:
|
||||
|
||||
```
|
||||
cd spring-batch-samples
|
||||
# Launch the test using the XML configuration
|
||||
../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithXmlConfig test
|
||||
# Launch the test using the Java configuration
|
||||
../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithJavaConfig test
|
||||
@@ -36,7 +36,7 @@ import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.sample.amqp.AmqpJobConfiguration;
|
||||
import org.springframework.batch.sample.rabbitmq.AmqpJobConfiguration;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
Reference in New Issue
Block a user