Server sided Database Reactivity - Run Tasks when new data is available

First things first: Yes, I know, I am building a message queue and yes, I know there are better “Databases” for that than mongo. But the Prototype needs to go live soon-ish and I don’t want to introduce yet another server.

Is there an easy way to define a Collection that will hold Jobs and as soon (or with some small delay) a new one comes in, it will trigger a server sided procedure in meteor?

e.g. observe but not for publications.
The server that will run these tasks is a stripped down version of meteor where everything is removed that belongs to the client.

You might want to examine to get some inspiration, or perhaps even use this one as your main infrastructure.

Or if you want to begin barebones, take a look at to react to new data on a collection (query).



or look at message queue as a service?

1 Like

maybe us collection hooks?

but still may want to use jobs for the task if it might fail.

@serkandurusoy what’s advantage of Mongo-Cursor-observe over collection hooks? same thing?

Enjoy :slight_smile:

1 Like

Well, practically, they can both be used for very similar things where the fundamental difference being collection hooks defined on collection’s instance methods whereas observe(changes) act reactively on a query cursor.

A rather important difference would be that;

A collection’s instance methods can only be tracked within the instance of an application (where the collection is defined and instantiated) whereas observe taps onto the database (oplog or poll) and can react to external changes.

1 Like