55 */
66namespace Magento \Framework \Amqp ;
77
8+ use Closure ;
9+ use Exception ;
810use Magento \Framework \MessageQueue \ConnectionLostException ;
911use Magento \Framework \MessageQueue \EnvelopeInterface ;
1012use Magento \Framework \MessageQueue \QueueInterface ;
11- use PhpAmqpLib \Exception \AMQPProtocolConnectionException ;
13+ use Magento \Framework \Phrase ;
14+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
1215use PhpAmqpLib \Message \AMQPMessage ;
1316use Magento \Framework \MessageQueue \EnvelopeFactory ;
1417use Psr \Log \LoggerInterface ;
@@ -73,11 +76,11 @@ public function dequeue()
7376 /** @var AMQPMessage $message */
7477 try {
7578 $ message = $ channel ->basic_get ($ this ->queueName );
76- } catch (AMQPProtocolConnectionException $ e ) {
79+ } catch (Exception $ exception ) {
7780 throw new ConnectionLostException (
78- $ e ->getMessage (),
79- $ e ->getCode (),
80- $ e
81+ $ exception ->getMessage (),
82+ $ exception ->getCode (),
83+ $ exception
8184 );
8285 }
8386
@@ -107,11 +110,11 @@ public function acknowledge(EnvelopeInterface $envelope)
107110 // @codingStandardsIgnoreStart
108111 try {
109112 $ channel ->basic_ack ($ properties ['delivery_tag ' ]);
110- } catch (AMQPProtocolConnectionException $ e ) {
113+ } catch (Exception $ exception ) {
111114 throw new ConnectionLostException (
112- $ e ->getMessage (),
113- $ e ->getCode (),
114- $ e
115+ $ exception ->getMessage (),
116+ $ exception ->getCode (),
117+ $ exception
115118 );
116119 }
117120 // @codingStandardsIgnoreEnd
@@ -135,7 +138,7 @@ public function subscribe($callback)
135138 // @codingStandardsIgnoreEnd
136139 $ envelope = $ this ->envelopeFactory ->create (['body ' => $ message ->body , 'properties ' => $ properties ]);
137140
138- if ($ callback instanceof \ Closure) {
141+ if ($ callback instanceof Closure) {
139142 $ callback ($ envelope );
140143 } else {
141144 call_user_func ($ callback , $ envelope );
@@ -165,7 +168,7 @@ public function reject(EnvelopeInterface $envelope, $requeue = true, $rejectionM
165168 // @codingStandardsIgnoreEnd
166169 if ($ rejectionMessage !== null ) {
167170 $ this ->logger ->critical (
168- new \ Magento \ Framework \ Phrase ('Message has been rejected: %message ' , ['message ' => $ rejectionMessage ])
171+ new Phrase ('Message has been rejected: %message ' , ['message ' => $ rejectionMessage ])
169172 );
170173 }
171174 }
0 commit comments