In an event based e commerce system using kafka, how do you handle auto expiring of orders in pending_payment status?
Typically, whenever there's a request from customer to create a new order there will be a message sent to topic so that inventory service can consume and reserve items the customer's order. Order
s status will transition to pending_payment
. For every order in pending_payment
status, the items in order will be reserved for 30 minutes. I want to auto expire the orders and rollback the item's quantity in a scalable way.
One way i can think of is to schedule a cron job in 30 minutes that will expire a particular order and put back the item's quantity, but is there a more efficient way to do this? Is creating a cron job for every order a feasible way ?