问题
I am designing a notification service (server). I can have two kinds of notifications: one which is delivered immediately, and the other is delivered at some time in the future.
Is there a framework to handle the future notifications?
I know I can write background worker who can for example sample the DB to look for a notification which needs to be sent, but I sure millions tried to solve this problem already and I'd prefer to reuse a proven solution.
I didn't decide yet on the framework / DB. I am thinking I should use either vertx.io or Jetty (WebSockets) for push notification. I am not sure regarding the DB because I wanted it to support those future notifications.
Update: How will you recommend I should save the data in DB for "live" notifications (notifications which exists in the users inbox) and for future notifications?
Update: I am thinking of using either:
- Jetty + Spring for WebSocket & SockJS + Quartz
- Vertx.io (Supports Websocket and Sockjs)
Any recommendation?
回答1:
One approach is to deliver the notifications to a Scheduling component. The scheduling component consumes all notifications, stores it and checks regularly to see if a notification is due to be sent out.
This will allow to attach a listener to the notifications and not pile up the notifications at publisher side.
来源:https://stackoverflow.com/questions/35230156/time-based-notification-architecture