Laravel Vapor Queue Dynamic DB Connection Issue for Different Requests

12 views Asked by At

I have Laravel Project running on vapor. (using SQS for Queue Driver) I have 2 webhook endpoints.

/webhook1
/webhook2

In webhook1 It's dispatching Job1

In webhook2 It's dispatching Job2

I needed to save in different database for webhook2 so I made 2nd configuration in mysql2

And in constructs of both webhook2 handler and Job2 class, I added following dynamic DB configuration.

config([
   'database.connections.mysql' => config('database.connections.mysql2'),
]);

So I assumed in webhook1 and Job1, data will be saved in database1 (mysql connection DB) and in webhook2 and Job2, data will be saved in database2 (mysql2 connection DB) but for some reason inside Job1 it was interacting with database2.

It was fine in webhook1 though. Only issue inside Queue which is Job1

How can I isolate this DB connection?

0

There are 0 answers