Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda