|
@@ -33,21 +33,21 @@ class MqConsumer extends ConsumerMessage
|
|
|
|
|
|
public function consumeMessage($data, AMQPMessage $message): Result
|
|
public function consumeMessage($data, AMQPMessage $message): Result
|
|
{
|
|
{
|
|
- $redis = $this->redisFactory->get('default');
|
|
|
|
- $lockKey = 'mq_consumer_lock';
|
|
|
|
- $lockValue = uniqid();
|
|
|
|
|
|
+ // $redis = $this->redisFactory->get('default');
|
|
|
|
+ // $lockKey = 'mq_consumer_lock';
|
|
|
|
+ // $lockValue = uniqid();
|
|
|
|
|
|
- // 获取锁
|
|
|
|
- $lockAcquired = $redis->setnx($lockKey, $lockValue);
|
|
|
|
- if (!$lockAcquired) {
|
|
|
|
- $this->logger->info('Another consumer instance is already running.');
|
|
|
|
- $this->logger->info($redis->get($lockKey));
|
|
|
|
- // return Result::ACK;
|
|
|
|
- return Result::REQUEUE;
|
|
|
|
- }
|
|
|
|
|
|
+ // // 获取锁
|
|
|
|
+ // $lockAcquired = $redis->setnx($lockKey, $lockValue);
|
|
|
|
+ // if (!$lockAcquired) {
|
|
|
|
+ // $this->logger->info('Another consumer instance is already running.');
|
|
|
|
+ // $this->logger->info($redis->get($lockKey));
|
|
|
|
+ // // return Result::ACK;
|
|
|
|
+ // return Result::REQUEUE;
|
|
|
|
+ // }
|
|
|
|
|
|
- // 设置锁过期时间,防止死锁
|
|
|
|
- $redis->expire($lockKey, 60);
|
|
|
|
|
|
+ // // 设置锁过期时间,防止死锁
|
|
|
|
+ // $redis->expire($lockKey, 60);
|
|
try {
|
|
try {
|
|
// 数据存储
|
|
// 数据存储
|
|
$this->logger->info('消费数据', ['data' => $data]);
|
|
$this->logger->info('消费数据', ['data' => $data]);
|