spring-boot/spring-boot-cli/samples/reactor.groovy
Phillip Webb bec1c8f00f Polish
2013-11-04 22:17:38 -08:00

31 lines
529 B
Groovy

package org.test
import java.util.concurrent.CountDownLatch;
@EnableReactor
@Log
class Runner implements CommandLineRunner {
@Autowired
Reactor reactor
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"
latch.await()
}
@Selector(reactor="reactor", value="hello")
void receive(String data) {
log.info "Hello ${data}"
latch.countDown()
}
}