2013-07-24 21:56:30 +08:00
|
|
|
package org.test
|
|
|
|
|
2013-07-31 05:03:56 +08:00
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
2013-07-24 21:56:30 +08:00
|
|
|
@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"
|
|
|
|
}
|
2013-07-24 21:56:30 +08:00
|
|
|
|
|
|
|
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-07-24 21:56:30 +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-07-24 21:56:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|