英文:
Notifying the Websocket when no message received in PUBSUB
问题
以下是我的信息监听器,用于监听Redis的PUBSUB。它正常工作。我需要实现这样一个功能,即如果在阈值/指定时间之后没有收到任何消息,那么我必须向WebSocket发送适当的消息(订阅URL与PUBSUB频道相同)。我目前没有找到任何方法可以实现这一点,因为会有许多客户端在不同的时间订阅不同的频道。
任何帮助或建议都将不胜感激。
public class PubSubListener implements MessageListener {
@Autowired
private SimpMessagingTemplate simpMessagingTemplate ;
@Override
public void onMessage(Message message, byte[] pattern) {
logger.info("从PUBSUB接收到消息");
simpMessagingTemplate.convertAndSend(new String(pattern), message.toString());
}
}
英文:
Below is my Message Listener which listens to Redis PUBSUB. It is working fine. I have to implement a feature in such a way that if no messages are received after threshold/specified time, then I have to send a proper message to websocket(subscription URL same as PUBSUB channel). I don't see any way to that as there will be many clients which subscribes to different channels at different times.
Any help or suggestion would be appreciable.
public class PubSubListener implements MessageListener {
@Autowired
private SimpMessagingTemplate simpMessagingTemplate ;
@Override
public void onMessage(Message message, byte[] pattern) {
logger.info(" MESSAGE RECEIVED FROM PUBSUB ");
simpMessagingTemplate.convertAndSend(new String(pattern), message.toString());
}
}
专注分享java语言的经验与见解,让所有开发者获益!
评论