Skip to content

Commit

Permalink
Allow to requeue message in google pub/sub
Browse files Browse the repository at this point in the history
  • Loading branch information
snapshotpl committed Apr 7, 2023
1 parent 0c6ff18 commit e3b271d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/gps/GpsConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,19 @@ public function acknowledge(Message $message): void
*/
public function reject(Message $message, bool $requeue = false): void
{
if (false == $message->getNativeMessage()) {
$nativeMessage = $message->getNativeMessage();

if (null === $nativeMessage) {
throw new \LogicException('Native google pub/sub message required but it is empty');
}

$this->getSubscription()->acknowledge($message->getNativeMessage());
$subscription = $this->getSubscription();

if ($requeue) {
$subscription->modifyAckDeadline($nativeMessage, 0);
} else {
$subscription->acknowledge($nativeMessage);
}
}

private function getSubscription(): Subscription
Expand Down

0 comments on commit e3b271d

Please sign in to comment.