Skip to content

Commit

Permalink
Constatnts with rabbit consumer return types (ack, nack, reject) move…
Browse files Browse the repository at this point in the history
…d to IConsumer
  • Loading branch information
paveljanda committed May 9, 2017
1 parent 6753ec9 commit 73442fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Consumer/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
final class Consumer
{

const MESSAGE_ACK = 1;
const MESSAGE_NACK = 2;
const MESSAGE_REJECT = 3;

/**
* @var string
*/
Expand Down Expand Up @@ -67,15 +63,15 @@ function (Message $message, Channel $channel, Client $client): void {
$result = call_user_func($this->callback, $message);

switch ($result) {
case self::MESSAGE_ACK:
case IConsumer::MESSAGE_ACK:
$channel->ack($message); // Acknowledge message
break;

case self::MESSAGE_NACK:
case IConsumer::MESSAGE_NACK:
$channel->nack($message); // Message will be requeued
break;

case self::MESSAGE_REJECT:
case IConsumer::MESSAGE_REJECT:
$channel->reject($message); // Message will be discarded
break;

Expand Down
4 changes: 4 additions & 0 deletions src/Consumer/IConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
interface IConsumer
{

const MESSAGE_ACK = 1;
const MESSAGE_NACK = 2;
const MESSAGE_REJECT = 3;

public function consume(Message $message): int;

}

0 comments on commit 73442fe

Please sign in to comment.