Customer stop message confirmation

I use the spring / stomp / websocket structure to asynchronously notify message users. I have done this successfully. However, I would get an ACK from the client so that some server-side action could happen when this is done.

A stream is approximately like a stream:

  • The service notifies a specific user of the decision and updates the record in the database with the status = "notification"
  • The client receives the message (using stompClient.subscribe (...))
  • The client confirms that the message has been received.
  • The service "knows" that this message is acknowledged and updates the status to "ACK" in the database.

    stompClient.connect({login:'guest', passcode:'guest'}, function(frame) { setConnected(true); **var headers = {ack: 'client'};** ... stompClient.subscribe('/user/guest/response',function(notification) { //doSomething }), **headers**); } 

A message has been sent to the service:

  this.messagingTemplate.convertAndSendToUser(user, "/response",msg, map); 

Is there a way to handle the client ACK on the server side? Alternatively I tried to do

 stompClient.send("/app/response/ack/"+messageId); 

on the client, in a method that processes the subscription, but in vain.

Can someone please tell me what is the standard way to process confirmations? I struggled with this for a couple of days, and any thoughts would be very helpful.

Thanks!

+6
source share
2 answers

Use the ACK frame according to spec . The server sends the ack:some_id , the client uses this some_id in the ACK frame.

+1
source

The answer to the request is no for a simple broker.

https://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html

A simple broker is great for getting started, but it only supports a subset of STOMP commands (for example, without quotes, receipts , etc.), relies on a simple message sending cycle and is not suitable for clustering. As an alternative, applications can switch to using a fully functional message broker.

0
source

Source: https://habr.com/ru/post/984458/


All Articles