1

I was going through the documentation available on Internet regarding sending/receiving messages using Spring Websocket STOMP. I could see various examples of sending messages from Backend to frontend (example given below) but don't see any examples to send the messages from frontend to backend.. Can someone please help?

//controller code this.simpMessagingTemplate.convertAndSend("/update/data", message)

//Frontend code stompClient.subscribe('/update/data', function ()...

2 Answers 2

0

Have you checked the stomp-js documentation? There is a (void) send(destination, headers = {}, body = '') declaration.

https://stomp-js.github.io/stomp-websocket/codo/class/Client.html

Sign up to request clarification or add additional context in comments.

Comments

0

Following the client-side code snippet, I can guess you are using the stompjs library for client setup.

Once your stompClient setup, the library offers a send method that you can use the to send messages for a specific messaging destination using the underlying STOMP-protocol SEND frame:

stompClient.send('/queue/some-queue', {}, "Some message");

The above line will send a STOMP message to the /queue/some-queue destination with empty ({}) headers and a Some messsage text.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.