Which is better: multiple web socket endpoints or single web socket endpoint in Java EE7

前端 未结 2 1070
天涯浪人
天涯浪人 2021-02-14 02:40

Java EE 7 allows you to create new endpoints very easily through annotations. However, I was wondering is having multiple endpoints one to handle each message type a good idea

2条回答
  •  礼貌的吻别
    2021-02-14 03:23

    Just noticed an ambiguity on my question re: message types. When I say message types I meant different kinds of application messages not native message types such as "binary" or "text". As such I marked @PavelBucek answer as the accepted one.

    However, I did try an experiment with Glassfish and having two end points. My suspicions were correct and that there is a TCP connection established per connected endpoint. This would cause more load on the server side if there is more than one websocket endpoint being used on a single page.

    As such I concluded that there should be only one endpoint to handle the application messages provided that everything is a single native type.

    This would mean that the application needs to do the dispatching rather than relying on some higher level API to do it for us.

提交回复
热议问题