Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

303
Vistas
stompjs how to get status after sending message

i'm creating a chat application with spring boot websocket, STOMP and stompjs, here is my js code:

<script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
<script>
    //some code

    //send message
    stompClient.send("/app/chat.sendMessage", {}, JSON.stringify(chatMessage));
</script>

Backend code:

@MessageMapping("/chat.sendMessage")
public MessageDTO sendMessage(@Payload MessageDTO chatMessage) {
    //HERE
    if(!validatorService.validate(chatMessage)) {
        throw new RuntimeException("invalid");
    }
    messagingTemplate.convertAndSend("/topic/public", chatMessage);
    return chatMessage;
}

You can see I return the message. In js side is there anyway to receive this object, something like

stompClient.send("/app/chat.sendMessage", {}, JSON.stringify(chatMessage), callback);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When a STOMP client sends a MESSAGE frame it usually won't get any response back from the broker at all. However, it may get back a RECEIPT frame if the MESSAGE frame included the receipt header. You aren't setting this header so you shouldn't expect any response back from the broker.

If you wanted to get some kind of application-specific response then you would need to create a subsriber in your JavaScript app and the server-side app would need to send a message to wherever that consumer was listening. This is the classic request/reply messaging pattern.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda