class DoctrineReceiver implements ListableReceiverInterface, MessageCountAwareInterface
{ private const MAX_RETRIES = 3;
private int
$retryingSafetyCounter = 0;
private Connection
$connection;
private SerializerInterface
$serializer;
public function __construct(Connection
$connection, SerializerInterface
$serializer = null
) { $this->connection =
$connection;
$this->serializer =
$serializer ??
new PhpSerializer();
} public function get(): iterable
{ try { $doctrineEnvelope =
$this->connection->
get();
$this->retryingSafetyCounter = 0; // reset counter
} catch (RetryableException
$exception) { // Do nothing when RetryableException occurs less than "MAX_RETRIES"
// as it will likely be resolved on the next call to get()
// Problem with concurrent consumers and database deadlocks