我尝试使用 QUARKUS 和 SmallRye 学习反应式编程/反应式消息传递。但是我仍然很难理解 org.eclipse.microprofile.reactive.messaging 相对于 javax.enterprise.event 的优势,如果有的话?
在一边 :
@Inject
MyEvent Event<String> myEvent;
public void someFunc(){
myEvent.fire("blabla");
}
//Elsewhere in the code :
public void aConsumer(@Observes @MyEvent String ev){
//an event saying blabla has been received :)
}
另一方面 :
@Inject
@Channel("myChannel")
Emitter<String> msgEmitter;
public void someFunc(){
msgEmitter.send("blabla");
}
//Elsewhere in the code :
@Incoming("myChannel")
public void aConsumer(String ev){
//an event saying blabla has been received :)
}
我可能会错过一些东西......