Last active
August 29, 2015 13:57
-
-
Save gsaqui/9675825 to your computer and use it in GitHub Desktop.
Groovy compile static not playing nicely with project reactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabResolver(name='org.projectreactor', root='http://repo.springsource.org/libs-milestone') | |
@Grab(group='org.projectreactor', module='reactor-core', version='1.1.0.M2') | |
@Grab(group='org.projectreactor', module='reactor-groovy', version='1.1.0.M2') | |
import reactor.core.Reactor | |
import reactor.core.spec.Reactors | |
import static reactor.event.selector.Selectors.$ | |
import groovy.transform.CompileStatic | |
final reactor.core.Environment env = new reactor.core.Environment() | |
final Reactor reactor = Reactors.reactor() | |
.env(env) // our current Environment | |
.dispatcher(reactor.core.Environment.THREAD_POOL) | |
.get(); | |
@CompileStatic | |
class Producer{ | |
Reactor r | |
void makeNoise(String noise){ | |
r.notify for: 'makeNoise', data: noise | |
} | |
} | |
class Consumer{ | |
Reactor r | |
void setupMessages(){ | |
r.on($('makeNoise')) { String noise -> | |
println noise | |
} | |
} | |
} | |
def consumer = new Consumer(r:reactor) | |
consumer.setupMessages() | |
def producer = new Producer(r:reactor) | |
producer.makeNoise('Yeah we is awesome') | |
println "done - you should see another println message" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment