0

I want to implement push notification in java so please help me out

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.

2-Content of the push notification should be the message present in the db.

3-If there are multiple messages, then the user should receive them one by one in a queue fashion.

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.

2
  • 1
    This is BROAD. I mean this involves both back-end and front-end (which framework), it's not something that can be contained in an answer. Commented Mar 12, 2019 at 14:14
  • Take a look at websocket, Spring has a good support. Commented Mar 12, 2019 at 15:53

1 Answer 1

1

You could use Server Sent Events. Java provides SseEmitter to send timely notifications. 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. Put SSE timeout to -1 for listening for an infinite amount of time.

Please note this answer is only a hint. Use these to explore more from the internet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.