I work with a message queue with 40 working listening daemons. There will always be messages in the queue, so workers are constantly working. There are messages in the queue for different clients, and I have to set up the database according to the xml data contained in the queue payload.
When using Config::set() to set the database at runtime, the data is inserted into various databases, in the correct tables, but in the wrong database. There are many identical databases.
I am trying to install a database using
Config::set('database.connections.usertable.database',$database);
just before connecting. I also tried Config::set() immediately before each (and also only one or one) $table->create() statement without success.
According to the Laravel documentation, Config::set() should only be valid for this request, but it looks like it confuses settings when there are multiple connections that set configuration values ββat the same time.
Although I solved the problem above by extending Model to setConnection() and getConnection() and another configuration, I am curious why this is happening.
Should the configuration be set only for the exact request in which it is installed?
source share