java - Websocket没有收到超过2条消息
问题描述
我们有一个后端 Java 应用程序,它会定期在石英作业上发布消息。Quartz 作业是按时间间隔安排的,并且运行良好。每条消息有 1 个作业,因为每条消息的间隔不同。如果有 3 条消息,则完美触发 3 个作业。
但我无法在前端接收消息,因为它只接收 2 而不是 3。
请问有什么预感吗??
我的工作代码:
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap dataMap = context.getMergedJobDataMap();
service = new BannerNotificationService();
String notificationId = dataMap.getString(NOTIFICATION_ID);
String INVALID_JOB = "-1";
if(!notificationId.equals(INVALID_JOB)){
try {
WebsocketEndPointHandler.sendMessageToAll(service.getNotificationDto(sendNotif));
} catch (IOException | EncodeException e) {
e.printStackTrace();
}
}
}
我的套接字处理程序代码:
public static void sendMessageToAll(NotificationDto message) throws IOException, EncodeException {
UserSessionHandler.endPoints.forEach(endpoint -> {
try {
endpoint.getBasicRemote().sendObject(new NotificationMessage().build(message));
} catch (IOException | EncodeException e) {
e.printStackTrace();
}
});
}
解决方案
推荐阅读
- schema.org - https://schema.org/ImageObject 的标题、描述或名称
- python - 如何在 postgresql 查询中处理空的 python 元组
- javascript - HTML 按钮未创建警报
- swift - 如何调整形状的大小以适合屏幕并将它们对齐到中心?
- google-chrome-devtools - 在 Chrome 开发工具中搜索 JSON
- javascript - JS点击和按键触发事件的时间差
- python - Django Redis 错误未知命令'BZPOPMIN'
- javascript - 使用地图“未捕获的 ReferenceError:未定义”错误获取请求
- c++11 - 无法理解如何递归合并排序
- ios - 以编程方式将图像设置为背景时出现 Swift 问题