Notifications best practices


Hello All,

I’m building an application that needs to send messages to logged-in users who are connected. I have a meteor cron job running that checks what messages to send to who every minute. To send them, I tried to use this package, which looks like it would do the job perfectly. However, I’m having trouble because I need to specify the userId of each particular user and send it to them only if they are logged in. I think this package doesn’t support sending messages based on userId (i think it filters messages on the client)

It seems like I could do this with a pub/sub function, and another collection, however, it doesn’t make sense to me to have a whole new mongodb collection just for sending events. I’d also have to delete these events as well.

is there any way to make a publish function that will automatically publish specific messages to individual clients without having to make another collection that gets periodically deleted?


I did the exact same thing: just added a collection for “messaging”. (In my case, I want a object that cannot be editted by the user, so I made a methode that returns it. If the object changes however, I do want to know. So I send a message in a collection, telling the Client to re-request the object from the methode.)
If you recieve it on the client, just delete it after you process it. It seems the collections are so efficient, worrying about it takes more energy than the server would spend actually serving them… :slight_smile:
(Obviously, that would change maybe if you will be sending a million a day…)