Reputation: 4572
Imagine a sales engine for perishable goods. Each item has an expiration date. A search index would index all the items for sale but is very interested in available for purchase counts as well as when all the items are expired.
To handle keeping up with the expiration dates in the search system I could:
Poll the data store on an interval and ask the system for items that have expired since the last time I looked and generate an update event to the search system. The search system could ask the data store for the current available items count and update the index appropriately.
Somehow schedule the expiration event when the item was added to the sales collection and have a processor simply process the event queue.
Ideas? I like the idea of scheduling future events however I'm not aware of technology that will help me delay delivery of the events until a specific time. Perhaps MS Service Bus can do this with LockedUntilUtc? There must be a pattern that people are using for this type of stuff and I just don't know what to search for.
Upvotes: 5
Views: 431
Reputation: 427
The choice of approach would depend entirely on your application. Scheduling events based on the expiry of an item would work well if there are significant number of items expiring at the same time. It runs the risk of too many events being scheduled if there are multiple items expiring at different times. But having only polling could easily cause sale of items which expire within two polling intervals.
Upvotes: 1