Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider Symfony retry policy #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions Tests/Transport/GpsSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PetitPress\GpsMessengerBundle\Transport\Stamp\OrderingKeyStamp;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;

/**
Expand Down Expand Up @@ -61,26 +60,6 @@ protected function setUp(): void
);
}

public function testItDoesNotPublishIfTheLastStampIsOfTypeRedelivery(): void
{
$envelope = EnvelopeFactory::create(new RedeliveryStamp(0));
$envelopeArray = ['body' => []];

$this->serializerMock
->expects($this->once())
->method('encode')
->with($envelope)
->willReturn($envelopeArray)
;

$this->pubSubClientMock
->expects($this->never())
->method('topic')
;

self::assertSame($envelope, $this->gpsSender->send($envelope));
}

public function testItPublishesWithOrderingKey(): void
{
$envelope = EnvelopeFactory::create(new OrderingKeyStamp(self::ORDERED_KEY));
Expand Down
2 changes: 1 addition & 1 deletion Transport/GpsReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function reject(Envelope $envelope): void

$this->pubSubClient
->subscription($this->gpsConfiguration->getSubscriptionName())
->modifyAckDeadline($gpsReceivedStamp->getGpsMessage(), 0)
->acknowledge($gpsReceivedStamp->getGpsMessage())
;
} catch (Throwable $exception) {
throw new TransportException($exception->getMessage(), 0, $exception);
Expand Down
7 changes: 0 additions & 7 deletions Transport/GpsSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PetitPress\GpsMessengerBundle\Transport\Stamp\OrderingKeyStamp;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\TransportException;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;

Expand Down Expand Up @@ -47,12 +46,6 @@ public function send(Envelope $envelope): Envelope
throw new TransportException($exception->getMessage(), 0, $exception);
}

$redeliveryStamp = $envelope->last(RedeliveryStamp::class);
if ($redeliveryStamp instanceof RedeliveryStamp) {
// do not try to redeliver, message wasn't acknowledged, so let's Google Pub/Sub do its job with retry policy
return $envelope;
}

$orderingKeyStamp = $envelope->last(OrderingKeyStamp::class);
if ($orderingKeyStamp instanceof OrderingKeyStamp) {
$messageBuilder = $messageBuilder->setOrderingKey($orderingKeyStamp->getOrderingKey());
Expand Down