Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - How to assure reliable message delivery of websockets?

I am developing a simple server whose primary task is to push notifications to users like a typical Push Notification Server. I have used java websockets for pushing the notification to the users through websocket session. While developing the same I have a list of some requirements in which reliable message delivery is one of the requirement.

I am pushing the notification to particular user like below,

session.getBasicRemote().sendObject(notification);

but above method returns void, thats why I am not able to conclude whether the notification is delivered to the other end or not. One of the option was, intended user will send feedback to my server for the same notification and I will mark the same notification as delivered successfully. But it could cause a increase in network traffic.

Is there any standard way to make sure that the notification is delivered successfully while sending it through websocket session

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The websockets specification is really low level and does not provide a confirmation for send messages. You have to either implement this yourself as an application-level protocol or use an existing protocol on top of websockets.

Stomp is a popular protocol which defines an "ACK" reply for consumed messages: Stomp specification


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...