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

33 lines
536 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 {
@Autowired
Reactor reactor
2013-07-31 05:03:56 +08:00
private CountDownLatch latch = new CountDownLatch(1)
@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-08-29 17:38:35 +08:00
@Selector(reactor="reactor", value="hello")
void receive(String data) {
log.info "Hello ${data}"
latch.countDown()
}
}