Search code examples
javascriptnode.jsgoogle-cloud-pubsubgoogle-api-nodejs-clientevent-driven

google cloud pub sub delayed messages


I am building an eCommerce system which includes biding implementation on offers, each offer can include more than one round and each round has startDate and endDate, after each round finishes I want to do other processes such as calculating the winning bids, losing bids, send a notification to users, go to the next round and update offer remaining quantity, all these stuff will work based on the round end date. We selected GC pub-sub as a solution to publish events and messages once the round is created and add listeners to this event to work and do the wanted processes, but the only missing thing in the solution is the ability to delay each message or scheduling it until the round end date comes then the listeners can work on

so how can I set a date or timestamp for each message when I publish them to be processed later when this date comes?

I am using node js


Solution

  • For using delayed message, you have to use Cloud Task. You have a sample code here line 67.