-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadvanced-consume.php
More file actions
33 lines (21 loc) · 893 Bytes
/
advanced-consume.php
File metadata and controls
33 lines (21 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
include __DIR__ . '/../vendor/autoload.php';
$connection = \Doctrine\DBAL\DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'path' => '/db/queue.db',
]);
$processor = static function(\Simple\Queue\Message $message, \Simple\Queue\Producer $producer): string {
// Your message handling logic
var_dump($message->getBody() . PHP_EOL);
return \Simple\Queue\Consumer::STATUS_ACK;
};
$config = \Simple\Queue\Config::getDefault()
->changeRedeliveryTimeInSeconds(100)
->changeNumberOfAttemptsBeforeFailure(3)
->registerProcessor('my_queue', $processor);
$transport = new \Simple\Queue\Transport\DoctrineDbalTransport($connection);
$producer = new \Simple\Queue\Producer($transport, $config);
$consumer = new \Simple\Queue\Consumer($transport, $producer, $config);
echo 'Start consuming' . PHP_EOL;
$consumer->consume();