forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreactor.groovy
More file actions
48 lines (35 loc) · 667 Bytes
/
reactor.groovy
File metadata and controls
48 lines (35 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.test
import java.util.concurrent.CountDownLatch
@EnableReactor
@Log
class Runner implements CommandLineRunner {
@Autowired
EventBus eventBus
private CountDownLatch latch = new CountDownLatch(1)
@PostConstruct
void init() {
log.info "Registering consumer"
}
void run(String... args) {
eventBus.notify("hello", Event.wrap("Phil"))
log.info "Notified Phil"
latch.await()
}
@Bean
CountDownLatch latch() {
latch
}
}
@Consumer
@Log
class Greeter {
@Autowired
EventBus eventBus
@Autowired
private CountDownLatch latch
@Selector(value="hello")
void receive(String data) {
log.info "Hello ${data}"
latch.countDown()
}
}