Skip to content

Commit

Permalink
Add Symfony scheduler for automatic queue triggering once a minute
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-moser committed Jan 16, 2024
1 parent 753f658 commit e6ef2eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"pimcore/enterprise-subscription-tools": "^1.3",
"pimcore/pimcore": "^11.0",
"opensearch-project/opensearch-php": "^2.2.0",
"doctrine/orm": "^2.17.2"
"doctrine/orm": "^2.17.2",
"symfony/scheduler": "^6.3|^7.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
tags: [ { name: messenger.message_handler, bus: messenger.bus.pimcore-generic-data-index } ]

Pimcore\Bundle\GenericDataIndexBundle\Service\TimeService: ~
Pimcore\Bundle\GenericDataIndexBundle\Scheduler\GenericDataIndexScheduleProvider: ~
Pimcore\Bundle\GenericDataIndexBundle\Installer:
public: true
arguments:
Expand Down
21 changes: 21 additions & 0 deletions src/Scheduler/GenericDataIndexScheduleProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);

namespace Pimcore\Bundle\GenericDataIndexBundle\Scheduler;

use Pimcore\Bundle\GenericDataIndexBundle\Message\DispatchQueueMessagesMessage;
use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;

#[AsSchedule('generic_data_index')]
class GenericDataIndexScheduleProvider implements ScheduleProviderInterface
{
public function getSchedule(): Schedule
{
return (new Schedule())->add(
RecurringMessage::every('1 minute', new DispatchQueueMessagesMessage())
);
}
}

0 comments on commit e6ef2eb

Please sign in to comment.