我有一个带有Websocket和Stomp的Spring应用程序以及一个RabbitMQ服务器集群。Websocket客户端被配置为发送心跳,RabbitMQ响应正常。我保留了服务器之间所有Websocket会话的分布式缓存,并在添加或删除连接时更新缓存。然而,在服务器宕机或连接丢失而未触发正确事件的情况下,该服务器上所有断开的连接将保留在缓存中,并使用我当前的配置。我正在考虑在Hazelcast上设置空闲时间,并以某种方式捕获心跳并在缓存上执行包含/获取以刷新项目。但是,我无法使用@MessageMaps
在控制器中捕获心跳,也无法找到心跳的侦听器。我如何实现这一点?
我想知道Broker可用性事件
是否适合您:
/**
* Creates a new {@code BrokerAvailabilityEvent}.
*
* @param brokerAvailable {@code true} if the broker is available, {@code}
* false otherwise
* @param source the component that is acting as the broker, or as a relay
* for an external broker, that has changed availability. Must not be {@code
* null}.
*/
public BrokerAvailabilityEvent(boolean brokerAvailable, Object source) {
它看起来像是从StompBrokerRelayMessageHandler. SystemSessionConnectionHandler.handleTcpConnectionFailure(String errorMessage,@Nullable Throwable ex)
发出的。