-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Messenger] Extend SQS visibility timeout for messages that are still…
… being processed
- Loading branch information
Showing
9 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
use Symfony\Component\Messenger\Exception\LogicException; | ||
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException; | ||
use Symfony\Component\Messenger\Exception\TransportException; | ||
use Symfony\Component\Messenger\Transport\Receiver\KeepaliveReceiverInterface; | ||
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface; | ||
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; | ||
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer; | ||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface; | ||
|
||
/** | ||
* @author Jérémy Derussé <[email protected]> | ||
*/ | ||
class AmazonSqsReceiver implements ReceiverInterface, MessageCountAwareInterface | ||
class AmazonSqsReceiver implements KeepaliveReceiverInterface, MessageCountAwareInterface | ||
{ | ||
private SerializerInterface $serializer; | ||
|
||
|
@@ -78,6 +78,15 @@ public function reject(Envelope $envelope): void | |
} | ||
} | ||
|
||
public function keepalive(Envelope $envelope, ?int $seconds = null): void | ||
{ | ||
try { | ||
$this->connection->keepalive($this->findSqsReceivedStamp($envelope)->getId(), $seconds); | ||
} catch (HttpException $e) { | ||
throw new TransportException($e->getMessage(), 0, $e); | ||
} | ||
} | ||
|
||
public function getMessageCount(): int | ||
{ | ||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
use AsyncAws\Core\Exception\Http\HttpException; | ||
use Symfony\Component\Messenger\Envelope; | ||
use Symfony\Component\Messenger\Exception\TransportException; | ||
use Symfony\Component\Messenger\Transport\Receiver\KeepaliveReceiverInterface; | ||
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface; | ||
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; | ||
use Symfony\Component\Messenger\Transport\Sender\SenderInterface; | ||
|
@@ -26,7 +27,7 @@ | |
/** | ||
* @author Jérémy Derussé <[email protected]> | ||
*/ | ||
class AmazonSqsTransport implements TransportInterface, SetupableTransportInterface, MessageCountAwareInterface, ResetInterface | ||
class AmazonSqsTransport implements TransportInterface, KeepaliveReceiverInterface, SetupableTransportInterface, MessageCountAwareInterface, ResetInterface | ||
{ | ||
private SerializerInterface $serializer; | ||
|
||
|
@@ -54,6 +55,14 @@ public function reject(Envelope $envelope): void | |
$this->getReceiver()->reject($envelope); | ||
} | ||
|
||
public function keepalive(Envelope $envelope, ?int $seconds = null): void | ||
{ | ||
$receiver = $this->getReceiver(); | ||
if ($receiver instanceof KeepaliveReceiverInterface) { | ||
$receiver->keepalive($envelope, $seconds); | ||
} | ||
} | ||
|
||
public function getMessageCount(): int | ||
{ | ||
return $this->getReceiver()->getMessageCount(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters