在@BalusC 的帮助下,我的 EJB 方法使用在 EE8 上运行的 JSF 2.3 在 JBoss WildFly 12.0.0.Final (MacOS) 上触发了一个事件:
beanManager.fireEvent("updateNotifications" );
POJO:
@Inject
@Push(channel = "testChannel")
private PushContext pushContext;
public void onPersist(@Observes String notification) {
logger.info("***** onPersist notification = {}", notification);
pushContext.send("updateNotifications");
}
接收并打印消息;
16:03:36,682 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB](默认任务 3)>>>>> insertFoodsCosmeticsMedicinesEJB beanManager = 用于 NOTiFYwell.ear/NOTiFYwellJAR.jar/ [bean count=39] 的焊接 BeanManager
16:03:36,695 INFO [com.notifywell.push.PushBean](默认任务 3)***** onPersist 通知 = updateNotifications
我无法通过 Push Send 与 XHTML 进行通信。我已经尝试过使用 OmniFaces 3.1 和 JBoss WildFly 12 JSF 2.3 并且没有重新渲染(此处未显示 XHTML 代码)。使用 OmniFaces 3.1 时,我无法显示 onmessage:
<h:form>
<o:socket channel="testChannel" onmessage="socketListener"/>
<h:outputScript>
function socketListener(message, channel, event) {
console.log(message);
}
</h:outputScript>
</h:form>
如果我在 Chrome 中打开控制台日志,它是空的,没有“消息”。
在 WireShark 我看到:
2601 9.810264 ::1 ::1 HTTP 997 GET /NOTiFYwell/omnifaces.push/testChannel?a1ef3363-dc5a-4153-a4c7-73b0e183713d HTTP/1.1
就好像
pushContext.send(notification);
没有被执行。