spring-boot/spring-boot-cli/samples/reactor.groovy

31 lines
529 B
Groovy
Raw Normal View History

package org.test
2013-07-31 05:03:56 +08:00
import java.util.concurrent.CountDownLatch;
@EnableReactor
@Log
class Runner implements CommandLineRunner {
2013-11-05 14:02:20 +08:00
@Autowired
Reactor reactor
2013-11-05 14:02:20 +08:00
2013-07-31 05:03:56 +08:00
private CountDownLatch latch = new CountDownLatch(1)
2013-11-05 14:02:20 +08:00
2013-07-31 05:03:56 +08:00
@PostConstruct
void init() {
log.info "Registering consumer"
}
void run(String... args) {
reactor.notify("hello", Event.wrap("Phil"))
log.info "Notified Phil"
2013-07-31 05:03:56 +08:00
latch.await()
}
2013-11-05 14:02:20 +08:00
2013-08-29 17:38:35 +08:00
@Selector(reactor="reactor", value="hello")
void receive(String data) {
log.info "Hello ${data}"
latch.countDown()
2013-11-05 14:02:20 +08:00
}
}