This sample application demonstrates a Spring Cloud Stream functional interface implementation of batch consuming and batch producing messages.
The application consists of a supplier that is generating a random UUID every second and a function that is configured through the kafka binder to wait 5 seconds until polling which then removes all integers from the UUID. The UUID is then produced as part of a batch, finally reaching a consumer that simply logs the digit-less UUID.
The application comes with a standard configuration properties yaml file that activates all the functions in the application.
It then specifies the necessary destinations for all the bindings.
Some bindings rely on the default binding destinations (see the application.yml
for details).
In addition, the application expects Kafka to be available on localhost:9092
.
If that is not the case, please ensure to update that in application.yml
.
To build the app simply execute the following command in the base directory:
./mvnw clean install
-
The app has been built by following the Building steps
-
Apache Kafka broker available at
localhost:9092
java -jar target/batch-producer-consumer-0.0.1-SNAPSHOT.jar
The application should automatically begin executing. All messages are printed in real-time as received by different parts of the application.
The output should look like the following:
5cce1056-34fc-4b7e-aadf-88c37eaa8a82 -> batch-in
3dc2e76d-d483-4cf8-98b8-44320124920a -> batch-in
6c00d120-0aa7-4373-bf3d-3bdbacb11adb -> batch-in
b4e8a7ff-19a7-44aa-8900-619caa78e885 -> batch-in
1626e7e6-87ba-4faa-97bf-a229e538bf7a -> batch-in
Removed digits from batch of 5
batch-out -> cce-fc-be-aadf-ceaaa
batch-out -> dced-d-cf-b-a
batch-out -> cd-aa--bfd-bdbacbadb
batch-out -> beaff-a-aa--caae
batch-out -> ee-ba-faa-bf-aebfa