Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

What is the major difference between SimpMessageHeaderAccessor vs StompHeaderAccessor Spring + java

Writer Andrew Mclaughlin

What is the major difference between SimpMessageHeaderAccessor vs StompHeaderAccessor Web Socket Spring?

Please explain elaborately if you know about this?

0

2 Answers

This has a simple answer: SimpMessageHeaderAccessor is the parent of StompHeaderAccessor.

That is, StompHeaderAccessor is used exclusively for STOMP headers while SimpMessageHeaderAccessor is used for all messaging protocol headers, including STOMP.


STOMP is one of the simpler types of messaging protocol - it's text based, making it a little similar to how HTTP works and allows for communication using multiple languages and platforms. But it cannot be used for queuing and topics.

Further reading:

Its important to understand the STOMP protocol, its design and format to better understand the API and the classes related.

STOMP´s interoperable wire format allows clients to communicate with number of message brokers. Since its language agnostic, clients and brokers developed in different languages can send and receive messages to each other.

STOMP complient message brokers are here.

STOMP is text-based and does not use binary protocols. It supports a range of core enterprise messaging features, such as authentication, messaging models like P2P & publish and subscribe, message acknowledgement, transactions, message headers & properties, etc.,

So while you use Spring Messaging framework to build client and server side Messaging platforms and applications, the package org.springframework.messaging.simp has generic support for Simple message protocols, STOMP is ONE of them.

As a base class of StompHeaderAccessor, can use SimpMessageHeaderAccessor for generic message header properties and use StompHeaderAccessor for STOMP specific properties like ContentLength, createForHeartbeat(), isHeartbeat() etc., and STOMP messaging API specific methods like updateStompCommandAsClientMessage(), updateStompCommandAsServerMessage(), wrap(Message<?> message).

Good examples on using StompHeaderAccessor can be found here. A good working example of using both SimpMessageHeaderAccessor and StompHeaderAccessor is available in this blog.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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