0

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?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Xavier Dury
  • 1,530
  • 1
  • 16
  • 23

1 Answers1

1

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:

  • Required
    • version
  • Optional
    • session
    • server
    • heart-beat

See the STOMP specification for more details.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • Hello, I am not sure if I agree with the changes (edits) you made to this question (`CONNECTED` -> `CONNECT`). The `CONNECT` frame is the one sent by the client to the server while the `CONNECTED` one is sent by the server to the client (https://stomp.github.io/stomp-specification-1.2.html#CONNECTED_Frame). In my case, I wanted to add a header in the one sent by the server to the client. – Xavier Dury May 04 '23 at 16:17
  • Thanks for the clarification. I rolled back the changes. – Justin Bertram May 04 '23 at 16:27