我正在使用spring-websocket和spring-messaging(版本4.2.2.RELEASE)实现带有完整功能代理的STOMP over websockets(Apache ActiveMQ 5.10.0)。我的客户端只能订阅目标,即它们不应该能够发送消息。此外,我想对客户端可以订阅的目标进行更严格的控制。无论哪种情况(即当客户端尝试发送消息或订阅无效目标时),我都希望能够:
- 发送适当的错误信息,和/或
- 关闭websocket连接
<websocket:message-broker
application-destination-prefix="/app">
<websocket:stomp-endpoint path="/pushchannel"/>
<websocket:stomp-broker-relay relay-host="localhost"
relay-port="61613" prefix="/topic"
heartbeat-receive-interval="300000" heartbeat-send-interval="300000" />
<websocket:client-inbound-channel>
<websocket:interceptors>
<bean class="MyClientMessageInterceptor"/>
</websocket:interceptors>
</websocket:client-inbound-channel>
</websocket:message-broker>
StompHeaderAccessor.create(StompCommand.ERROR)
,然后使用SimpMessagingTemplate发送它。我会看看这是否可行... - Nenaddestination
设置为什么?我的理解是destination
是客户端订阅的STOMP目标。那么当发送一个无效的订阅请求的ERROR帧时,我应该使用什么作为目标呢? - Nenad