Java PrimeFaces@PushEndpoint和@PathParam有时不起作用
我使用的是PrimeFaces 6.0和Atmosphere运行时2.4.3。我在下面的聊天示例中遇到了“未知”问题,推送消息有时有效,有时无效。我一直在尝试调试,以了解问题是什么,但到目前为止没有运气 我在这里发布了配置和代码,几乎与我们有很多示例一样Java PrimeFaces@PushEndpoint和@PathParam有时不起作用,java,primefaces,atmosphere,primefaces-push,Java,Primefaces,Atmosphere,Primefaces Push,我使用的是PrimeFaces 6.0和Atmosphere运行时2.4.3。我在下面的聊天示例中遇到了“未知”问题,推送消息有时有效,有时无效。我一直在尝试调试,以了解问题是什么,但到目前为止没有运气 我在这里发布了配置和代码,几乎与我们有很多示例一样 1. pom.xml <dependency> <groupId>org.primefaces</groupId> <artifactId>pri
1. pom.xml
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.3</version>
</dependency>
2. web.xml
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
3. Resource class
@PushEndpoint(value="/{room}/{user}")
@Singleton
public class RoomResource {
@PathParam("room")
private String room;
@PathParam("user")
private String user;
@OnOpen
public void onOpen() {
logger.info("onOpen {} for room {} and user {}", new String[]{endpoint.toString(), this.room, this.user});
eventBus.publish(room + "/*", "test data");
}
We push the message as
eventBus.publish("/room_111" + "/*", "user data");
The output is
Sometime onOpen give output as
onOpen AtmosphereResource{
uuid=187feb09-c9da-4b5d-afe6-5c19c0b4868b,
transport=WEBSOCKET,
isInScope=true,
isResumed=false,
isCancelled=false,
isSuspended=true,
broadcasters=/{room}/1234,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=SUSPEND}} for room **null** and **user** null
1。pom.xml
org.primefaces
素面
${primefaces.version}
组织气氛
大气运行时间
2.4.3
2.web.xml
推送Servlet
org.primefaces.push.PushServlet
0
真的
推送Servlet
/primepush/*
3.资源类
@PushEndpoint(value=“/{room}/{user}”)
@独生子女
公共教室资源{
@PathParam(“房间”)
私人弦乐室;
@PathParam(“用户”)
私有字符串用户;
@奥诺彭
公共开放(){
logger.info(“房间{}和用户{}的onOpen{}”,新字符串[]{endpoint.toString(),this.room,this.user});
发布(房间+“/*”,“测试数据”);
}
我们把这条消息当作
发布(“/room_111”+“/*”,“用户数据”);
输出是
有时,onOpen将输出作为
开放式大气源{
uuid=187feb09-c9da-4b5d-afe6-5C19C0B486B,
传输=WEBSOCKET,
isInScope=true,
isResumed=false,
isCancelled=false,
isSuspended=true,
广播员=/{room}/1234,
isClosedByClient=false,
isclosedbyaapplication=false,
action=action{timeout=-1,type=SUSPEND}}用于房间**null**和**用户**null
但有时我看到房间和用户的数据是正确的
请提供建议和帮助
请帮助我理解@PushEndpoint(value=“/{room}/{user}”)是什么
如果我们发送“/room_1/123”或“/room_2/345”,这意味着我们将消息推送到同一频道,对吗
我感觉该频道工作不够稳定。有时该消息没有发送给订阅该频道的所有人。我完全卡住了。请帮助
更新:
共有3例,均为意外发生
谢谢,有人能在这个问题上帮助我吗?有人有这方面的经验吗?请与我联系并提供帮助有人能在这个问题上帮助我吗?有人有这方面的经验吗?请与我联系并提供帮助