I am working on a multi-tenant multi-database architecture application using Laravel which basically means that every tenant in the application has their own database, own sets of users, resources and so on.
Now I am trying to implement queues and caching in the application, then I am trying to use redis for that. A sample code looks like this:
$mailer->send('emails.welcome', ['user' => $user], function ($message) use ($user) {
$message->from("admin@admin.com", "Admin");
$message->to($user->email, $user->first_name)->subject("Welcome!");
});
This is to send a welcome email to user sign-up. But the queuing is storing all the queues in the same database in the same Redis instance, different tenant emails will get mixed up as far as I can tell.
How do I hook into Laravel 5 and change the queue behavior to either store the jobs for each tenant in a separate database or store extra meta-information about the tenant a particular job belongs to? And then also how would I tell Laravel to parse that extra meta-information and connect to the right tenant database before proceeding with the job?