File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
src/Symfony/Component/Messenger Expand file tree Collapse file tree 2 files changed +19
-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 ;
16
+ use Doctrine \DBAL \Exception \DriverException ;
14
17
use PHPUnit \Framework \TestCase ;
15
18
use Symfony \Component \Messenger \Envelope ;
16
19
use Symfony \Component \Messenger \Exception \MessageDecodingFailedException ;
@@ -68,6 +71,17 @@ public function testItRejectTheMessageIfThereIsAMessageDecodingFailedException()
68
71
$ receiver ->get ();
69
72
}
70
73
74
+ public function testOccursRetryableExceptionFromConnection ()
75
+ {
76
+ $ serializer = $ this ->createSerializer ();
77
+ $ connection = $ this ->createMock (Connection::class);
78
+ $ driverException = new PDOException (new \PDOException ('Deadlock ' , 40001 ));
79
+ $ connection ->method ('get ' )->willThrowException (new DeadlockException ('Deadlock ' , $ driverException ));
80
+ $ receiver = new DoctrineReceiver ($ connection , $ serializer );
81
+ $ actualEnvelopes = $ receiver ->get ();
82
+ $ this ->assertSame ([], $ actualEnvelopes );
83
+ }
84
+
71
85
public function testAll ()
72
86
{
73
87
$ 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