Manuel Jordan
Manuel Jordan

Reputation: 16281

Spring websocket: how intercept the send event through the AbstractSubProtocolEvent hierarchy?

About Spring websocket about intercept Stomp events one approach is extends from the ChannelInterceptorAdapter class

It works how is expected. More details here:

Now, according with this tutorial:

the approach mentioned above is covered and other approach is work around with ApplicationEvents, it through with:

These classes extends from:

And exists two subclasses more:

This list is confirmed in (by the same author):

The names are by themselves obvious to know what each one does, but just curious

It to react from:

stompClient.send('/app/ws/something', 
                 {}, 
                 JSON.stringify({'content': $('#content').val()})

For this send event "seems" mandatory work with the ChannelInterceptorAdapter through the postSend(Message<?> message, MessageChannel channel, boolean sent) method yet

Upvotes: 0

Views: 539

Answers (1)

Rossen Stoyanchev
Rossen Stoyanchev

Reputation: 5008

The events reflect major points in the lifecycle of a STOMP connection. They're not meant to be notifications for every message sent from the client. For that you can use @MessageMapping methods, or a ChannelInterceptor.

Upvotes: 2

Related Questions