In a weld bean (not EJB), I'm trying to handle an event Asynchronously. To do so I'm trying to fire an asynchronous event using Event.fireAsync and then catch the event using a method that takes the event object as parameter and is annotated with @ObservesAsync annotation. The fireAsync does run, but the @ObservesAsync method is never called.
@Inject
Event<CustomEvent> customEvent;
public void sendEvent(ObjectRequest request) {
customEvent.fireAsync(new CustomEvent(request))
.thenAccept((CustomEvent) -> {
logger.info(">>>> Event thenAccept");
});
}
public void handeEvent(@ObservesAsync CustomEvent customEvent) {
logger.info("||||||| Received CustomEvent");
this.attribute= logProcessing(customEvent.getRequest());
}
PS: Using Event.fire and @Observes does work , but is not asynchronous which I need this code to be.