File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/Symfony/Component/Messenger Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Messenger \Tests \Transport \Doctrine ;
13
13
14
+ use Doctrine \DBAL \Driver \PDOException ;
15
+ use Doctrine \DBAL \Exception \DeadlockException ;
14
16
use PHPUnit \Framework \TestCase ;
15
17
use Symfony \Component \Messenger \Envelope ;
16
18
use Symfony \Component \Messenger \Exception \MessageDecodingFailedException ;
@@ -68,6 +70,17 @@ public function testItRejectTheMessageIfThereIsAMessageDecodingFailedException()
68
70
$ receiver ->get ();
69
71
}
70
72
73
+ public function testOccursRetryableExceptionFromConnection ()
74
+ {
75
+ $ serializer = $ this ->createSerializer ();
76
+ $ connection = $ this ->createMock (Connection::class);
77
+ $ driverException = new PDOException (new \PDOException ('Deadlock ' , 40001 ));
78
+ $ connection ->method ('get ' )->willThrowException (new DeadlockException ('Deadlock ' , $ driverException ));
79
+ $ receiver = new DoctrineReceiver ($ connection , $ serializer );
80
+ $ actualEnvelopes = $ receiver ->get ();
81
+ $ this ->assertSame ([], $ actualEnvelopes );
82
+ }
83
+
71
84
public function testAll ()
72
85
{
73
86
$ serializer = $ this ->createSerializer ();
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Messenger \Transport \Doctrine ;
13
13
14
14
use Doctrine \DBAL \DBALException ;
15
+ use Doctrine \DBAL \Exception \RetryableException ;
15
16
use Symfony \Component \Messenger \Envelope ;
16
17
use Symfony \Component \Messenger \Exception \LogicException ;
17
18
use Symfony \Component \Messenger \Exception \MessageDecodingFailedException ;
@@ -46,6 +47,10 @@ public function get(): iterable
46
47
{
47
48
try {
48
49
$ doctrineEnvelope = $ this ->connection ->get ();
50
+ } catch (RetryableException $ exception ) {
51
+ // Do nothing when RetryableException occurs.
52
+ // Problem with concurent consumers and Database Deadlocks
53
+ return [];
49
54
} catch (DBALException $ exception ) {
50
55
throw new TransportException ($ exception ->getMessage (), 0 , $ exception );
51
56
}
You can’t perform that action at this time.
0 commit comments