INT-4360: Add ClientStompEncoder support

The `StompSubProtocolHandler` explicitly sets `stompCommand` header
to the `MESSAGE` value ignoring any client inputs.
In this case the message is treated as from the server and ignored on
the STOMP Broker side from the client session.

* Introduce `ClientStompEncoder` for the client side to be injected
into the `StompSubProtocolHandler` for the proper client side messages
encoding/decoding.
Override `stompCommand` header to the `SEND` value if it is `MESSAGE`
before encoding to the `byte[]` to send to the session

JIRA: https://jira.spring.io/browse/INT-4360

**Cherry-pick to 4.3.x**

Fix WebSocket test to rely on the proper client config class
and don't pick up the server config unconditionally in the test context
This commit is contained in:
Artem Bilan
2017-10-30 14:28:51 -04:00
committed by Gary Russell
parent 2712e28074
commit 8766262399
5 changed files with 85 additions and 24 deletions

View File

@@ -433,3 +433,12 @@ Defaults to `false`.
<13> See the same option on the `<int-websocket:outbound-channel-adapter>`.
[[client-stomp-encoder]]
=== ClientStompEncoder
Starting with _version 4.3.13_, the `ClientStompEncoder` is provided as an extension of standard `StompEncoder` for using on client side of the WebSocket Channel Adapters.
An instance of the `ClientStompEncoder` must be injected into the `StompSubProtocolHandler` for proper client side message preparation.
One of the problem of the default `StompSubProtocolHandler` that it was designed for the server side, so it updates the `SEND` `stompCommand` header into `MESSAGE` as it must be by the STOMP protocol from server side.
If client doesn't send its messages in the proper `SEND` web socket frame, some STOMP brokers won't accept them.
The purpose of the `ClientStompEncoder`, in this case, is to override `stompCommand` header to the `SEND` value before encoding the message to the `byte[]`.