Skip to content

Commit 73d0afb

Browse files
committed
Polish chapter 6 code
1 parent a5dd994 commit 73d0afb

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

6/part3/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// tag::spring-cloud[]
12
buildscript {
23
ext {
34
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
45
springCloudVersion = 'Finchley.BUILD-SNAPSHOT'
56
}
7+
// end::spring-cloud[]
68
repositories {
79
mavenCentral()
810
maven { url "https://repo.spring.io/snapshot" }
@@ -54,15 +56,19 @@ dependencies {
5456
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
5557
compile('org.springframework.boot:spring-boot-starter-actuator')
5658
compile('org.springframework.boot:spring-boot-devtools')
59+
// tag::scst[]
5760
compile('org.springframework.cloud:spring-cloud-starter-stream-rabbit')
5861
compile('org.springframework.cloud:spring-cloud-stream-reactive')
62+
// end::scst[]
5963
compile('org.projectlombok:lombok')
6064
testCompile('org.springframework.boot:spring-boot-starter-test')
6165
testCompile("io.projectreactor:reactor-test")
6266
}
6367

68+
// tag::scst-2[]
6469
dependencyManagement {
6570
imports {
6671
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
6772
}
6873
}
74+
// end::scst-2[]

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public CommentController(CounterService counterService) {
4747
this.flux = Flux.<Message<Comment>>create(
4848
emitter -> this.commentSink = emitter,
4949
FluxSink.OverflowStrategy.IGNORE)
50-
.publish()
51-
.autoConnect();
50+
.publish()
51+
.autoConnect();
5252
}
5353

5454
@PostMapping("/comments")
@@ -65,8 +65,7 @@ public Mono<String> addComment(Mono<Comment> newComment) {
6565
}
6666

6767
@StreamEmitter
68-
@Output(Source.OUTPUT)
69-
public void emit(FluxSender output) {
68+
public void emit(@Output(Source.OUTPUT) FluxSender output) {
7069
output.send(this.flux);
7170
}
7271

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ public CommentService(CommentWriterRepository repository,
5050
// tag::stream-2[]
5151
@StreamListener
5252
@Output(Processor.OUTPUT)
53-
public Flux<Void> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
53+
public Flux<Void> save(@Input(Processor.INPUT)
54+
Flux<Comment> newComments) {
5455
return repository
55-
.saveAll(newComment)
56+
.saveAll(newComments)
5657
.flatMap(comment -> {
5758
counterService.increment(
5859
"comments.total.consumed");
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
1+
# tag::settings[]
22
spring:
3-
http:
4-
multipart:
5-
max-file-size: 10MB
63
cloud:
74
stream:
85
bindings:
@@ -12,11 +9,12 @@ spring:
129
output:
1310
destination: learning-spring-boot-comments
1411
group: learning-spring-boot
12+
# end::settings[]
13+
# tag::logs[]
1514
logging:
1615
level:
1716
org:
18-
rabbitmq: TRACE
1917
springframework:
20-
amqp: TRACE
21-
cloud: TRACE
22-
integration: TRACE
18+
cloud: DEBUG
19+
integration: DEBUG
20+
# end::logs[]

0 commit comments

Comments
 (0)