【发布时间】:2018-04-18 17:34:45
【问题描述】:
在@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 信息 [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);
没有被执行。
【问题讨论】:
-
你在浏览器中调试过网络流量吗?
-
使用 Wireshark 过滤 tcp.port == 8080 && http。我看到我的单元测试正在运行。是否显示 HTTP GET 和 OK 200 的响应。
-
“好像
pushContext.send(notification)没有被执行。” 调试... -
uhhhh 如果您从 ide 在容器中运行您的应用程序,您应该能够调试...
-
如果你有minimal reproducible example 我可以尝试复制。但我不会尝试复制。但是 f: websockets 有效吗?这有什么不同吗?
标签: jsf wildfly omnifaces jsf-2.3