Skip to content

Commit c12daec

Browse files
Report job failures to failed jobs provider (#31)
* Report job failures to failed jobs provider * sort imports Co-authored-by: Till Krüss <tillkruss@users.noreply.github.com>
1 parent 330cbfd commit c12daec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/BrefServiceProvider.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
use Illuminate\Contracts\Http\Kernel;
1313
use Illuminate\Contracts\Events\Dispatcher;
1414

15+
use Illuminate\Queue\Events\JobFailed;
1516
use Illuminate\Queue\Events\JobProcessed;
1617
use Illuminate\Queue\Events\JobProcessing;
1718
use Illuminate\Queue\Events\JobExceptionOccurred;
19+
use Illuminate\Queue\Failed\FailedJobProviderInterface;
1820

1921
class BrefServiceProvider extends ServiceProvider
2022
{
@@ -67,7 +69,7 @@ public function register()
6769
*
6870
* @return void
6971
*/
70-
public function boot(Dispatcher $dispatcher, LogManager $logManager)
72+
public function boot(Dispatcher $dispatcher, LogManager $logManager, FailedJobProviderInterface $queueFailer)
7173
{
7274
if ($this->app->runningInConsole()) {
7375
$this->publishes([
@@ -99,6 +101,15 @@ public function boot(Dispatcher $dispatcher, LogManager $logManager)
99101
['name' => $event->job->resolveName()]
100102
)
101103
);
104+
105+
$dispatcher->listen(
106+
fn (JobFailed $event) => $queueFailer->log(
107+
$event->connectionName,
108+
$event->job->getQueue(),
109+
$event->job->getRawBody(),
110+
$event->exception
111+
)
112+
);
102113
}
103114

104115
/**

0 commit comments

Comments
 (0)