@@ -92,10 +92,16 @@ public function ack(Envelope $envelope): void
92
92
try {
93
93
$ stamp = $ this ->findAmqpStamp ($ envelope );
94
94
95
- $ this ->connection ->ack (
96
- $ stamp ->getAmqpEnvelope (),
97
- $ stamp ->getQueueName ()
98
- );
95
+ $ this ->connection ->ack ($ stamp ->getAmqpEnvelope (), $ stamp ->getQueueName ());
96
+ } catch (\AMQPConnectionException ) {
97
+ try {
98
+ $ stamp = $ this ->findAmqpStamp ($ envelope );
99
+
100
+ $ this ->connection ->queue ($ stamp ->getQueueName ())->getConnection ()->reconnect ();
101
+ $ this ->connection ->ack ($ stamp ->getAmqpEnvelope (), $ stamp ->getQueueName ());
102
+ } catch (\AMQPException $ exception ) {
103
+ throw new TransportException ($ exception ->getMessage (), 0 , $ exception );
104
+ }
99
105
} catch (\AMQPException $ exception ) {
100
106
throw new TransportException ($ exception ->getMessage (), 0 , $ exception );
101
107
}
@@ -124,6 +130,13 @@ private function rejectAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, string $queueNa
124
130
{
125
131
try {
126
132
$ this ->connection ->nack ($ amqpEnvelope , $ queueName , \AMQP_NOPARAM );
133
+ } catch (\AMQPConnectionException ) {
134
+ try {
135
+ $ this ->connection ->queue ($ queueName )->getConnection ()->reconnect ();
136
+ $ this ->connection ->nack ($ amqpEnvelope , $ queueName , \AMQP_NOPARAM );
137
+ } catch (\AMQPException $ exception ) {
138
+ throw new TransportException ($ exception ->getMessage (), 0 , $ exception );
139
+ }
127
140
} catch (\AMQPException $ exception ) {
128
141
throw new TransportException ($ exception ->getMessage (), 0 , $ exception );
129
142
}
0 commit comments