Skip to content

Commit 89e3808

Browse files
committed
Updated properties and README for Kafka and AMQP
resolves #745
1 parent 2cba0f2 commit 89e3808

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

spring-cloud-task-samples/single-step-batch-job/README.adoc

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Single Step Batch JOb
1+
= Single Step Batch Job
22

33
This is a Spring Cloud Task application that autoconfigures a single step Spring Batch job based on the profiles that are active.
44

@@ -8,6 +8,10 @@ The profiles that are available are:
88
* `ffwriter` - Activates a FlatFileItemWriter that writes to the `result.txt` file.
99
* `jdbcreader` - Activates a JdbcCursorItemReader that reads from the `item_sample` table.
1010
* `jdbcwriter` - Activates a JdbcItemReader that writes to the `item` table.
11+
* `amqpreader` - Activates a AmqpItemReader that reads from the `samplequeue` queue.
12+
* `amqpwriter` - Activates a AmqpItemWriter that writes to the `sampleexchange` exchange.
13+
* `kafkareader` - Activates a KafkaItemReader that reads from the `sampletopic` topic.
14+
* `kafkawriter` - Activates a KafkaItemWriter that writes to the `sampletopic` topic.
1115
1216
== Requirements:
1317

@@ -98,3 +102,41 @@ INSERT INTO item_sample (item_name) VALUES ('boo');
98102
INSERT INTO item_sample (item_name) VALUES ('qux');
99103
INSERT INTO item_sample (item_name) VALUES ('Job');
100104
```
105+
106+
=== FlatfileItemReader with AmqpItemWriter batch job
107+
In this example the batch job will read from the `test.txt` file and write the result to the `sampleexchange` exchange.
108+
```
109+
java -Dspring.profiles.active=ffreader,amqpwriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
110+
```
111+
112+
NOTE: Before running create an exchange named `sampleexchange`.
113+
114+
=== AmqpItemReader with FlatfileItemWriter batch job
115+
In this example the batch job will read from the `samplequeue` queue and write the result to the `result.txt` in the current directory.
116+
```
117+
java -Dspring.profiles.active=amqpreader,ffwriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
118+
```
119+
120+
NOTE: Before running create and populate a queue named `samplequeue`.
121+
122+
=== FlatfileItemReader with KafkaItemWriter batch job
123+
In this example the batch job will read from the `test.txt` file and write the result to the `sampletopic` topic.
124+
```
125+
java -Dspring.profiles.active=ffreader,kafkawriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
126+
```
127+
128+
Before running create a topic named `sampletopic`. For example:
129+
```
130+
kafka-topics.sh --create --topic sampletopic --bootstrap-server localhost:9092
131+
```
132+
133+
=== KafkaItemReader with FlatfileItemWriter batch job
134+
In this example the batch job will read from the `sampletopic` topic and write the result to the `result.txt` in the current directory.
135+
```
136+
java -Dspring.profiles.active=kafkareader,ffwriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
137+
```
138+
139+
Before running populate the topic named `sampletopic`. For example populate it using the FlatfileItemReader and KafkaItemWriter from above:
140+
```
141+
java -Dspring.profiles.active=ffreader,kafkawriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
142+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring.batch.job.amqpitemreader.name=testreader
2+
spring.cloud.task.closecontextEnabled=true
3+
spring.batch.job.amqpitemreader.enabled=true
4+
spring.rabbitmq.template.defaultReceiveQueue=samplequeue
5+
spring.rabbitmq.host=localhost
6+
spring.rabbitmq.port=5672
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spring.batch.job.amqpitemwriter.enabled=true
2+
spring.cloud.task.closecontextEnabled=true
3+
spring.rabbitmq.template.exchange=sampleexchange
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
spring.kafka.consumer.bootstrapServers=localhost:9092
2+
spring.batch.job.kafkaitemreader.name=testreader
3+
spring.kafka.consumer.groupId=1
4+
spring.kafka.consumer.bootstrapServers=localhost:9092
5+
spring.kafka.consumer.valueDeserializer=org.springframework.kafka.support.serializer.JsonDeserializer
6+
spring.kafka.consumer.keyDeserializer=org.springframework.kafka.support.serializer.JsonDeserializer
7+
spring.batch.job.kafkaitemreader.topic=sampletopic
8+
spring.batch.job.kafkaitemreader.pollTimeOutInSeconds=2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spring.kafka.producer.bootstrapServers=localhost:9092
2+
spring.kafka.producer.keySerializer=org.springframework.kafka.support.serializer.JsonSerializer
3+
spring.kafka.producer.valueSerializer=org.springframework.kafka.support.serializer.JsonSerializer
4+
spring.batch.job.kafkaitemwriter.topic=sampletopic

0 commit comments

Comments
 (0)