java - Spring websocket STOMP Unsubscribe from eventHandler -
i have spring websocket stomp application accepts subscribe requests.
in application have handler subscribe, is,
@component public class subscribestompeventhandler implements applicationlistener<sessionsubscribeevent> { @override public void onapplicationevent(sessionsubscribeevent event) {} }
that use validate subscription.
in case if subscription invalid, instance, current user can not see subscription, broker (i use simplemessagingbroker) "forget" subscription, or preferably, not register @ all.
my questions are:
can make broker not register subscription, if move handling of subscription request incoming message interceptor , stop message propagation?
what else used event handler cancel subscription?
you need create channelinterceptor
implementation. extend channelinterceptoradapter
, override presend(message<?> message, messagechannel channel)
. here access headers session information validation. need registrate interceptor
@override public void configuremessagebroker(messagebrokerregistry registry) { registry.configurebrokerchannel().setinterceptors(new yourinterceptor()) registry.enablesimplebroker("/queue/", "/topic/"); registry.setapplicationdestinationprefixes("/app"); }
more information here how reject topic subscription based on user rights spring-websocket
Comments
Post a Comment