I'm trying to make a service that runs operations at one time, these operations are specified by another service by mail, here's the scenario:
- Service A receives a request for object creation, the service stores the object in its own database.
- For each object, an operation must be executed at a specified time in the object
- In attempting to establish commercial limits, Service B will be responsible for the execution of the above operations; Indeed, the role of the operation is to create a session accessible to customers (think of a discussion room that starts at the X hour and ends at the Y time).
- I'm trying to follow a korean architecture, so I would like Service B to know which operations to execute and when to execute them
- According to this, the service A will simply send messages to the service B on the operations to be performed and when they must be executed.
The problem is what is the best strategy for service B as soon as it receives messages; I've thought of 2 solutions:
- As soon as service B receives a message, it stores the information in a dedicated database; the service can then check each X for operations to run on the database, but this can affect performance because it requires continuous access and querying of the database.
- Once Service B receives a message, it launches a timer that will execute the operations at the specified time. this will reduce operations to the minimum required, but if the service falls for any reason, all timers will disappear. This would involve writing a logic to restore the timers gone and already started.
I do not know if these are the best solutions. Is there another strategy I can use?