Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java PrimeFaces@PushEndpoint和@PathParam有时不起作用_Java_Primefaces_Atmosphere_Primefaces Push - Fatal编程技术网

Java PrimeFaces@PushEndpoint和@PathParam有时不起作用

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

我使用的是PrimeFaces 6.0和Atmosphere运行时2.4.3。我在下面的聊天示例中遇到了“未知”问题,推送消息有时有效,有时无效。我一直在尝试调试,以了解问题是什么,但到目前为止没有运气

我在这里发布了配置和代码,几乎与我们有很多示例一样

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例,均为意外发生

  • 正确的 11:29:22信息[http-bio-8080-exec-7]:pad.controller.TestResource.onOpen()43-onOpen AtmosphereResource{ uuid=e6aa499b-6962-446e-a26f-f9ca1f768335, 传输=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, 广播员=/{112室}/9999, isClosedByClient=false, isclosedbyaapplication=false, action=action{timeout=-1,type=SUSPEND}用于房间{room_112}和用户9999

  • 错误案例1 11:27:54信息[http-bio-8080-exec-8]:pad.controller.TestResource.onOpen()43-onOpen AtmosphereResource{ uuid=b43d6cea-cdcd-498f-b83b-7377130f5a34, 传输=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, 广播员=/{room_112};JSSessionID=9082465FABC76CC67477F2BC8C513D7A/9999, isClosedByClient=false, isclosedbyaapplication=false, action=action{timeout=-1,type=SUSPEND}用于房间{room_112};jsessionid=9082465FABC76CC67477F2BC8C513D7A和用户9999

  • 错误案例2 11:29:06信息[http-bio-8080-exec-2]:pad.controller.TestResource.onOpen()43-onOpen AtmosphereResource{ uuid=a34f7912-47ac-4f22-a7d5-f56a545bcea5, 传输=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, 广播员=/{112室}/9999, isClosedByClient=false, isclosedbyaapplication=false, action=action{timeout=-1,type=SUSPEND}}用于房间null和用户null


  • 谢谢,

    有人能在这个问题上帮助我吗?有人有这方面的经验吗?请与我联系并提供帮助有人能在这个问题上帮助我吗?有人有这方面的经验吗?请与我联系并提供帮助