Batching up notifications

Viewed 60

I have a simple chat messaging system where users can send one-on-one messages to each other. It uses SignalR to send chat messages, and then the messages are stored in a database in this format:

SenderId | RecipientId | Message | SentDateTime | RecipientHasRead

Currently, when a userA sends a message to userB, the SignalR service immediately sends a push notification to userB at the same time as saving the message to the datbase.

UserB can then get overloaded with lots of notification. I need some way to batch the notifications.

For example, currently User B will get the following notifications:

10:00am: User A has sent you a new message 10:01am: User A has sent you a new message 10:01am: User A has sent you a new message 10:01am: User C has sent you a new message

I would prefer that User B will get something like this:

10:01am: You have 4 unread messages

What are some techniques to implement this? Should I just run a job every 5 minutes to check un-read messages for a given user in the past 5 mins and send that out?

0 Answers
Related