springstompspring-messaging

Adding custom headers to STOMP CONNECTED frame with Spring


Is it possible to add a custom header to the STOMP CONNECTED frame in Spring?

From what I have found in StompSubProtocolHandler, a CONNECT_ACK SiMP message gets converted to a CONNECTED STOMP message without retaining any header. So if a ChannelInterceptor.preSend() adds a custom header to the CONNECT_ACK message, that header won't be sent (in the CONNECTED message).

Is there any reason why it is like this? Is there any way to get around this limitation?


Solution

  • The STOMP protocol doesn't allow arbitrary, user-defined headers in the CONNECTED frame. Only the SEND, MESSAGE, and ERROR frames support arbitrary headers. The CONNECTED frame supports the following headers in addition to the standard headers:

    See the STOMP specification for more details.