# 6.6.4: Scheduled Task run() method will nicht ausführen

**URL:** https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588
**Category:** Programmierung
**Tags:** programming
**Created:** [18. Juli 2024 um 14:36 UTC](https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588 "2024-07-18T14:36:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maximilian.ehrhardt](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@maximilian.ehrhardt](https://forum.shopware.com/u/maximilian.ehrhardt)
#### Post date: [18. Juli 2024 um 14:36 UTC](https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588/1 "2024-07-18T14:36:35Z")

</div>

Hi liebe Shopware Community,

wir versuchen seit Tagen in der 6.6.4 einen Scheduled Task zum Laufen zu bringen.

Dieser wird auch über systemd alle 15 min richtig scheduled; allerdings wird die run method nie ausgeführt und wir sind kurz vorm Verzweifeln ;( Docs, Videos, alles durch…

Habt ihr eine Idee? Beste Grüße

**Task:**  
custom/plugins/EcomListing/src/Task/EcomListingTask.php

```auto
<?php declare(strict_types=1);

namespace EcomListing\Task;

use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;

class EcomListingTask extends ScheduledTask
{
    public static function getTaskName(): string
    {
        return 'ecom.listing';
    }

    public static function getDefaultInterval(): int
    {
        return 60 * 15; // 15 minutes
    }

    public static function shouldRescheduleOnFailure(): bool
    {
        return true;
    }
}

```

**Task Handler**  
custom/plugins/EcomListing/src/Task/EcomListingTaskHandler.php

```auto
<?php declare(strict_types=1);

namespace EcomListing\Task;

use Psr\Log\LoggerInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Doctrine\DBAL\Connection;

#[AsMessageHandler(handles: EcomListingTask::class)]
class EcomListingTaskHandler extends ScheduledTaskHandler
{
    public function __construct(
        EntityRepository $scheduledTaskRepository,
        private readonly LoggerInterface $logger,
        private readonly Connection $connection,
    ) {
        parent::__construct($scheduledTaskRepository, $logger);
        //$this->logger->info(EcomListingTask::getTaskName() . '----------> construct ');
    }

    public function run(): void
    {

        $this->logger->info(EcomListingTask::getTaskName() . '----------> run ');

        $query = $this->connection->createQueryBuilder();
        $query->update('product', 'p')
                     ->set('p.is_closeout', 1);

        try {
            $result = $query->executeQuery();
        } catch (\Doctrine\DBAL\Exception $err) {
            $this->logger->error($err->getMessage());
        }  

        $this->logger->info(EcomListingTask::getTaskName() . '----------> finished ');
    }
}

```

**DI**  
custom/plugins/EcomListing/src/Resources/config/services.xml

```auto
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="EcomListing\Task\EcomListingTask">
            <tag name="shopware.scheduled.task"/>
        </service>

        <service id="EcomListing\Task\EcomListingTaskHandler">
            <argument type="service" id="scheduled_task.repository"/>
            <argument type="service" id="logger"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <tag name="messenger.message_handler"/>
        </service>

    </services>

</container>

```

---

<div class="post-metadata">

### Author: ![radek.kohut](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@radek.kohut](https://forum.shopware.com/u/radek.kohut)
#### Post date: [8. August 2024 um 06:11 UTC](https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588/2 "2024-08-08T06:11:58Z")

</div>

Dein EcomListingTaskHandler solte Attribute AsMessageHandler importieren:

`use Symfony\Component\Messenger\Attribute\AsMessageHandler;`

---

<div class="post-metadata">

### Author: ![maximilian.ehrhardt](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@maximilian.ehrhardt](https://forum.shopware.com/u/maximilian.ehrhardt)
#### Post date: [9. August 2024 um 11:24 UTC](https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588/3 "2024-08-09T11:24:59Z")

</div>

oh man… danke, danke - das wars!

---

<div class="post-metadata">

### Author: ![system](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/2/9/29c7587ba660f00e4995d1743162782e5d6d8653.svg) [@system](https://forum.shopware.com/u/system)
#### Post date: [8. September 2024 um 11:26 UTC](https://forum.shopware.com/t/6-6-4-scheduled-task-run-method-will-nicht-ausfuehren/104588/4 "2024-09-08T11:26:00Z")

</div>

Dieses Thema wurde automatisch 30 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.
