transactionsmulti-tenanttransactionscopedistributed-transactionsoutbox-pattern

Design / Implement Transactional Outbox pattern in schema isolated multitenant application


I have a multi-tenant application. The tenants data is isolated based on schema.

I want to implement a transactional outbox pattern, where I want to store the events in a table (in same transaction)and then send events later with a job.

I am planning to keep the events table in each tenant schema, so that it can be updated in the same transaction. I cannot keep the events table in common (application) schema because then I cannot update the table in same transaction...

Now my problem is how will the job (quartz / spring based) know which all schema needs to be checked for events? There can be several tenant schema where there were no events to be processed.


Solution

  • One approach is to replace cron jobs with CDC (bin logs for MySQL). You can do the entire processing in the CDC handler or you can use it to update some central table that keeps track of which tenant has new messages.