CDI: How to notify ViewScoped bean from SessionScoped bean with no active request/view context

1 week ago 6
ARTICLE AD BOX

I have a Quarkus + Camel + Primefaces app/service which receives messages from AMQ Artemis. The receiving bean is ApplicationScopped and it also re-sends certain events to specific SessionBean(s).

Is there a good/standard way to forward some events from the SessionBean to currently active related ViewScoped bean(s)? All the forwarding (Camel route -> ApplicationScoped -> SessionScoped -> ViewScopped) happens in the same thread with no active request context, not using any reactive components.

What I tried with no luck (ViewScoped bean listener is never called) so far:

added @ActivateRequestContext annotation to the ApplicationScoped bean observer method (called by Camel processor on message arrival from AMQ) and firing event destined to ViewScopped beans from there.

tried to make ViewScoped bean to self register as a listener to SessionScoped bean using the object reference. Registration part works, but I cant call the ViewScoped bean by the reference due to "jakarta.enterprise.context.ContextNotActiveException: ViewScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean". Annotating entry method with @ActivateRequestContext doesn't help.

Is this a valid/supported use case? Any pointers for making it work?

Read Entire Article