5
5
*/
6
6
namespace Magento \Framework \Amqp ;
7
7
8
+ use Closure ;
9
+ use Exception ;
8
10
use Magento \Framework \MessageQueue \ConnectionLostException ;
9
11
use Magento \Framework \MessageQueue \EnvelopeInterface ;
10
12
use Magento \Framework \MessageQueue \QueueInterface ;
11
- use PhpAmqpLib \Exception \AMQPProtocolConnectionException ;
13
+ use Magento \Framework \Phrase ;
14
+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
12
15
use PhpAmqpLib \Message \AMQPMessage ;
13
16
use Magento \Framework \MessageQueue \EnvelopeFactory ;
14
17
use Psr \Log \LoggerInterface ;
@@ -73,11 +76,11 @@ public function dequeue()
73
76
/** @var AMQPMessage $message */
74
77
try {
75
78
$ message = $ channel ->basic_get ($ this ->queueName );
76
- } catch (AMQPProtocolConnectionException $ e ) {
79
+ } catch (Exception $ exception ) {
77
80
throw new ConnectionLostException (
78
- $ e ->getMessage (),
79
- $ e ->getCode (),
80
- $ e
81
+ $ exception ->getMessage (),
82
+ $ exception ->getCode (),
83
+ $ exception
81
84
);
82
85
}
83
86
@@ -107,11 +110,11 @@ public function acknowledge(EnvelopeInterface $envelope)
107
110
// @codingStandardsIgnoreStart
108
111
try {
109
112
$ channel ->basic_ack ($ properties ['delivery_tag ' ]);
110
- } catch (AMQPProtocolConnectionException $ e ) {
113
+ } catch (Exception $ exception ) {
111
114
throw new ConnectionLostException (
112
- $ e ->getMessage (),
113
- $ e ->getCode (),
114
- $ e
115
+ $ exception ->getMessage (),
116
+ $ exception ->getCode (),
117
+ $ exception
115
118
);
116
119
}
117
120
// @codingStandardsIgnoreEnd
@@ -135,7 +138,7 @@ public function subscribe($callback)
135
138
// @codingStandardsIgnoreEnd
136
139
$ envelope = $ this ->envelopeFactory ->create (['body ' => $ message ->body , 'properties ' => $ properties ]);
137
140
138
- if ($ callback instanceof \ Closure) {
141
+ if ($ callback instanceof Closure) {
139
142
$ callback ($ envelope );
140
143
} else {
141
144
call_user_func ($ callback , $ envelope );
@@ -165,7 +168,7 @@ public function reject(EnvelopeInterface $envelope, $requeue = true, $rejectionM
165
168
// @codingStandardsIgnoreEnd
166
169
if ($ rejectionMessage !== null ) {
167
170
$ 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 ])
169
172
);
170
173
}
171
174
}
0 commit comments