I'm using Larevel 5.5's built-in Redis queue. While I was writing a test queuing a payload, I noticed that the testing does not recognize the default queue name I have assigned in queue.php:
'connections' => [
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'tickets',
]
I'm inserting a payload to the queue like this: Job::dispacth($payload). It's working as intended in the actual non-test code.
-
Why isn't this sending the payload to
ticketsqueue? I have to explicitly assign a queue name for the testing. i.e.->onQueue('tickets'). If it's ignoring it intentionally, where can I find reference to such behavior? -
I ended up tracing back
dispatch()to see why #1 was so, but I only came to find that it is a weird (see #3) instantiation of the classIlluminate\Foundation\Bus\PendingDispatchlike below:// Illuminate\Foundation\Bus\Dispatchable public static function dispatch() { return new PendingDispatch(new static(...func_get_args())); } // Illuminate\Foundation\Bus\PendingDispatch public function __construct($job) { $this->job = $job; }How does
dispatchinsert the payload into the queue? Is event-based, magic, or? -
What is
new PendingDispatch(new static(...func_get_args()));exactly doing? Psecifically, I'm don't know whatnew staticis doing as the constructor's argument.PendingDispatch's constructor doesn't even take multiple arguments.
Aucun commentaire:
Enregistrer un commentaire