Skip to content

Commit

Permalink
[Queue] Add end message to instant logs #1234
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jun 16, 2024
1 parent cb155cb commit 575de2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Core/Application/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ private function handleListener(
if ($listener instanceof Closure) {
// Closure with ListenTo() attribute
$event = AttributesAccessor::getFirstAttributeInstance($listener, ListenTo::class);
$event->listen($dispatcher, $listener);
$event->listen(
$dispatcher,
fn (...$args) => $container->call($listener, $args)
);
} else {
// Simply listener class name.
$dispatcher->subscribe($container->resolve($listener));
Expand Down
13 changes: 13 additions & 0 deletions src/Core/Queue/Command/QueueWorkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Windwalker\Core\Queue\QueueManager;
use Windwalker\Core\Service\LoggerService;
use Windwalker\DI\Exception\DefinitionException;
use Windwalker\Queue\Driver\DatabaseQueueDriver;
use Windwalker\Queue\Event\AfterJobRunEvent;
use Windwalker\Queue\Event\BeforeJobRunEvent;
use Windwalker\Queue\Event\JobFailureEvent;
use Windwalker\Queue\Event\LoopEndEvent;
Expand Down Expand Up @@ -212,6 +214,17 @@ function (BeforeJobRunEvent $event) {
);
}
)
->on(
AfterJobRunEvent::class,
function (AfterJobRunEvent $event) {
$this->app->addMessage(
sprintf(
'Job Message: <info>%s</info> END',
$event->getMessage()->getId()
)
);
}
)
->on(
JobFailureEvent::class,
function (JobFailureEvent $event) use ($io, $connection) {
Expand Down

0 comments on commit 575de2b

Please sign in to comment.