Skip to content

Commit a3ee002

Browse files
committed
Fix Spring Cloud Streams reactive
1 parent b59e46f commit a3ee002

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

6/part3/src/main/java/com/greglturnquist/learningspringboot/comments/CommentService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.greglturnquist.learningspringboot.comments;
1717

1818
import reactor.core.publisher.Flux;
19+
import reactor.core.publisher.Mono;
1920

2021
import org.springframework.boot.CommandLineRunner;
2122
import org.springframework.boot.actuate.metrics.CounterService;
@@ -49,7 +50,7 @@ public CommentService(CommentWriterRepository repository,
4950
// tag::stream-2[]
5051
@StreamListener
5152
@Output(Processor.OUTPUT)
52-
public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
53+
public Mono<Void> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
5354
return repository
5455
.saveAll(newComment)
5556
.map(comment -> {
@@ -58,7 +59,8 @@ public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
5859
counterService.increment(
5960
"comments." + comment.getImageId() + ".consumed");
6061
return comment;
61-
});
62+
})
63+
.then();
6264
}
6365
// end::stream-2[]
6466

6/part3/src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ spring:
77
stream:
88
bindings:
99
input:
10+
destination: learning-spring-boot-comments
1011
group: learning-spring-boot
1112
output:
13+
destination: learning-spring-boot-comments
1214
group: learning-spring-boot
1315
logging:
1416
level:

0 commit comments

Comments
 (0)