Skip to content

Latest commit

 

History

History
57 lines (46 loc) · 1.38 KB

methods.md

File metadata and controls

57 lines (46 loc) · 1.38 KB

Methods

enqueue

The enqueue method takes a object from \Da\Mailer\Model\MailJob class as parameter. It pushes the object to the end of the queue.

$message = new \Da\Mailer\Model\MailMessage([
    'from' => '[email protected]',
    'to' => '[email protected]',
    'subject' => 'What is up?',
    'textBody' => 'I hope to find you well...'
]);

$queue = \Da\Mailer\Queue\MailQueue::make();
$mailJob = \Da\Mailer\Builder\MailJobBuilder::make([
    'message' => $message
]);

if (! $queue->enqueue($mailJob)) {
    // something wrong happened
}

dequeue

The dequeue method fetches the very next job on the queue.

$mailJob = \Da\Mailer\Queue\MailQueue::make()->dequeue();
var_dump($mailJob);

// output:
// class Da\Mailer\Queue\Backend\RabbitMq\RabbitMqJob#32 (5) {
//  private $deliveryTag =>
//  ...

ack

The ack method takes an object from the \Da\Mailer\Model\MailJob class. It is responsible to inform the broker about a message status. If the message is full processed and completed (literally have to MailJob with the property isCompleted as true. You can check how to assess it here), the broker will remove it from new rounds, otherwise, it'll requeue it.

$queue->ack($mailJob);

isEmpty()

Return true if there is no messages in the queue, otherwise, return false.

$queue->isEmpty();
// false