简体   繁体   English

Java,Spring,推送通知

[英]Java,Spring,Push Notification

I want to implement push notification in java so please help me out我想在java中实现推送通知所以请帮帮我

1-Each time a new record(Message) pushed into data base(due to event created by some other user), a push notification should be sent to specific Logged in user automatically. 1-每次将新记录(消息)推送到数据库时(由于其他用户创建的事件),应自动向特定的登录用户发送推送通知。

2-Content of the push notification should be the message present in the db. 2-推送通知的内容应该是数据库中存在的消息。

3-If there are multiple messages, then the user should receive them one by one in a queue fashion. 3-如果有多条消息,那么用户应该以队列的方式一一接收它们。

4-Most important thing is the logged in user need not have to trigger any event to get notification, user should receive it automatically throughout the session. 4-最重要的是登录用户不需要触发任何事件来获取通知,用户应该在整个会话期间自动接收它。

You could use Server Sent Events.您可以使用服务器发送的事件。 Java provides SseEmitter to send timely notifications. Java 提供了 SseEmitter 来及时发送通知。 You can use EventSource API in JavaScript to trigger the SSE event stream and in the server-side, loop the database query code which is wrapped by an ExecutorService - which can spin of separate thread based on the initialization.您可以在 JavaScript 中使用 EventSource API 来触发 SSE 事件流,并在服务器端循环由 ExecutorService 包装的数据库查询代码 - 可以根据初始化旋转单独的线程。 Put SSE timeout to -1 for listening for an infinite amount of time.将 SSE 超时设置为 -1 以监听无限长的时间。

Please note this answer is only a hint.请注意,这个答案只是一个提示。 Use these to explore more from the internet.使用这些从互联网上探索更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM