Skip to content

03.Queue

Muhammet ŞAFAK edited this page Aug 31, 2024 · 1 revision

Queue

Queue classes and objects are responsible for consuming or producing messages in a specific queue in the message broker service through an adapter. Every queue class must implement \PHPQueueManager\PHPQueueManager\Queue\QueueInterface and \PHPQueueManager\PHPQueueManager\Queue\Queue should extends.

namespace App\Queues;

use \PHPQueueManager\PHPQueueManager\Queue\{QueueInterface, Queue};

class NotificationQueue extends Queue implements QueueInterface
{

    public function __construct()
    {
        $adapter = new \PHPQueueManager\PHPQueueManager\Adapters\RabbitMQ\RabbitMQAdapter([
            'host'          => 'localhost',
            'port'          => 5672,
            'username'      => 'guest',
            'password'      => 'guest',
        ]);

        parent::__construct($adapter);
    }


    /**
     * @inheritDoc
     */
    public function getName(): string
    {
        return 'notification_queue';
    }

    /**
     * @inheritDoc
     */
    public function getDLQName(): string
    {
        return 'notification_queue_deadletterqueue';
    }

}
Clone this wiki locally