Best way to ignore ‘duplicate’ commands

Apologies if this has been covered before but my searches haven’t uncovered anything
I have a scheduler which sends a SyncCommand to an endpoint every 5 mins. The command has one of many possible TenantId’s as a property, but each command has a unique commandID
The saga should only do single processing per tenant (multiple tenant processing simultaneously though) and may take a short time or occasionally much longer than 5 mins
What is the best way of ignoring or discarding incoming commands if that tenant is currently processing?
I have looked at outbox but not sure how that would be utilised
Is uniform session applicable?
Or do I just match saga on TenantId and somehow consume the multiple incoming commands, but basically ignoring them since the saga is still processing for that tenantID?

@Gobba,

to better understand the scenario, how do you handle the case when the saga processing exceeds the transport timeout?
What transport and persistence are you using?

.m

Thanks for your reply

For timeouts, I check if it’s still processing (regularly updating a timestamp in the state during valid processing) and extend the timeout if needed
For valid timeouts I markascomplete, publishing an error notification event

Am using SqlPersistance
Using Azure ServiceBus in production and RabbitMQ for local development

You probably need to design a sort of semaphore saga that acts like a decision-maker and a blocker if the saga that does the actual work is still running.

  • The scheduler sends a message (the command with a unique ID and a tenant ID)
  • The semaphore saga is triggered and is mapped to the unique command ID
    • It checks (by looking at the saga data) is a long-running job for the combination to tenant and command is already running
    • If it is, it rejects the command; otherwise, it pulls off the long-running job saga by sending an internal command
  • When the long-running job saga finishes, it replies back to the semaphore saga that removes from its saga data the tenant and command combination acting like a semaphore for simultaneous executions

Does it make sense to you, @Gobba?

.m

Thanks for your reply, it does make sense. It sounds a little complicated so will have to digest it further
Much appreciated
Alan

@Gobba,

if you need to get on a call to discuss this further, please do not hesitate to contact me. We can go through your requirements and brainstorm options together.

.m

1 Like