Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

301
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!