In my JSF application I'm trying to use web sockets to push updates from backend to frontend. The backend publishes messages on an ActiveMQ topic which I'm listening to (on @ApplicationScoped level).
I've got two channels which are created by injecting on a @WebListener, like this:
@Inject
public void setControllerEventChannel(@Push(channel = "controllerEventChannel") PushContext controllerEventChannel) {
this.controllerEventChannel = controllerEventChannel;
}
@Inject
public void setGroupEventChannel(@Push(channel = "groupEventChannel") PushContext groupEventChannel) {
this.groupEventChannel = groupEventChannel;
}
<o:socket channel="controllerEventChannel" onmessage="onMessage" />
<h:commandScript name="onMessage" actionListener="#{backingBean.controllerChannelCallback()}"
process="@this" update="@none"/>
The challenge is, I've got many controllers and many groups. How do I push messages on these channels such that all opened views don't receive all callbacks? The views are controller or group specific. My current solution is filtering events in the actionListener method and it's, in a word, terrible.
I wish I could create channels dynamically, but I don't there's a way to do that in JakartaEE?
For this you can use the
userattribute,with
Or even
with