@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | foreach ($taggedProducers as $id => $tags) { |
| 24 | 24 | $producerName = $tags[0]['producer']; |
| 25 | - $originLogger = $id . '.logger'; |
|
| 25 | + $originLogger = $id.'.logger'; |
|
| 26 | 26 | |
| 27 | 27 | if ($container->hasDefinition($originLogger)) { |
| 28 | 28 | $consumerDef = $container->getDefinition($id); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | foreach ($taggedConsumers as $id => $tags) { |
| 36 | 36 | $consumerName = $tags[0]['consumer']; |
| 37 | - $originLogger = $id . '.logger'; |
|
| 37 | + $originLogger = $id.'.logger'; |
|
| 38 | 38 | |
| 39 | 39 | if ($container->hasDefinition($originLogger)) { |
| 40 | 40 | $consumerDef = $container->getDefinition($id); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->container = $container; |
| 53 | 53 | |
| 54 | - $loader = new XmlFileLoader($this->container, new FileLocator(array(__DIR__ . '/../Resources/config'))); |
|
| 54 | + $loader = new XmlFileLoader($this->container, new FileLocator(array(__DIR__.'/../Resources/config'))); |
|
| 55 | 55 | $loader->load('rabbitmq.xml'); |
| 56 | 56 | |
| 57 | 57 | $configuration = $this->getConfiguration($configs, $container); |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function loadExchanges($exchanges): array |
| 105 | 105 | { |
| 106 | - return array_map(function ($exchange) { |
|
| 106 | + return array_map(function($exchange) { |
|
| 107 | 107 | $exchangeDeclaration = new Definition(ExchangeDeclaration::class); |
| 108 | 108 | $exchangeDeclaration->setProperties($exchange); |
| 109 | 109 | |
| 110 | - foreach($this->loadBindings($exchange['bindings'], $exchange['name'], null) as $binding) { |
|
| 110 | + foreach ($this->loadBindings($exchange['bindings'], $exchange['name'], null) as $binding) { |
|
| 111 | 111 | $this->container->getDefinition('old_sound_rabbit_mq.declaration_registry')->addMethodCall('addBinding', [$binding]); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function loadQueues($queues): array |
| 123 | 123 | { |
| 124 | - return array_map(function ($queue, $key) use ($queues) { |
|
| 124 | + return array_map(function($queue, $key) use ($queues) { |
|
| 125 | 125 | $queue['name'] = $queue['name'] ?? $key; |
| 126 | 126 | $queueDeclaration = new Definition(QueueDeclaration::class); |
| 127 | 127 | $queueDeclaration->setProperties($queue); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | foreach ($this->config['consumers'] as $consumerName => $consumer) { |
| 257 | 257 | $alias = sprintf('old_sound_rabbit_mq.consumer.%s', $consumerName); |
| 258 | - $serializerAlias = sprintf('old_sound_rabbit_mq.consumer.%s.serializer', $consumerName);// TODO |
|
| 258 | + $serializerAlias = sprintf('old_sound_rabbit_mq.consumer.%s.serializer', $consumerName); // TODO |
|
| 259 | 259 | |
| 260 | 260 | $connectionName = $consumer['connection'] ?? 'default'; |
| 261 | 261 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $definition->addTag('old_sound_rabbit_mq.consumer', ['consumer' => $consumerName]); |
| 267 | 267 | // TODO $this->container->setAlias($serializerAlias, SerializerInterface::class); |
| 268 | 268 | // $definition->addMethodCall('setSerializer', [new Reference($serializerAlias)]);} |
| 269 | - foreach($consumer['consumeQueues'] as $index => $consumeQueue) { |
|
| 269 | + foreach ($consumer['consumeQueues'] as $index => $consumeQueue) { |
|
| 270 | 270 | $queueConsumingDef = new Definition(QueueConsuming::class); |
| 271 | 271 | $queueConsumingDef->setProperties([ |
| 272 | 272 | 'queueName' => $consumeQueue['queue'], |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $definition->addTag('monolog.logger', [ |
| 432 | 432 | 'channel' => 'phpamqplib' |
| 433 | 433 | ]); |
| 434 | - $loggerAlias = $definitionAlias . '.loggeer'; |
|
| 434 | + $loggerAlias = $definitionAlias.'.loggeer'; |
|
| 435 | 435 | $this->container->setAlias($loggerAlias, 'logger'); |
| 436 | 436 | $definition->addMethodCall('setLogger', [new Reference($loggerAlias, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]); |
| 437 | 437 | } |
@@ -102,19 +102,18 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | protected function setup(): Consumer |
| 104 | 104 | { |
| 105 | - foreach($this->queueConsumings as $index => $queueConsuming) { |
|
| 105 | + foreach ($this->queueConsumings as $index => $queueConsuming) { |
|
| 106 | 106 | $this->channel->basic_qos($queueConsuming->qosPrefetchSize, $queueConsuming->qosPrefetchCount, false); |
| 107 | 107 | |
| 108 | 108 | $consumerTag = $this->channel->basic_consume( |
| 109 | 109 | $queueConsuming->queueName, |
| 110 | 110 | $queueConsuming->consumerTag ? |
| 111 | - $queueConsuming->consumerTag : |
|
| 112 | - sprintf("PHPPROCESS_%s_%s_%s", gethostname(), getmypid(), $index), |
|
| 111 | + $queueConsuming->consumerTag : sprintf("PHPPROCESS_%s_%s_%s", gethostname(), getmypid(), $index), |
|
| 113 | 112 | $queueConsuming->noLocal, |
| 114 | 113 | $queueConsuming->noAck, |
| 115 | 114 | $queueConsuming->exclusive, |
| 116 | 115 | $queueConsuming->nowait, |
| 117 | - function (AMQPMessage $message) use ($queueConsuming) { |
|
| 116 | + function(AMQPMessage $message) use ($queueConsuming) { |
|
| 118 | 117 | $this->getExecuteReceiverStrategy($queueConsuming)->consumeCallback($message); |
| 119 | 118 | }); |
| 120 | 119 | |
@@ -140,12 +139,11 @@ discard block |
||
| 140 | 139 | $this->queueConsumings[] = $queueConsuming; |
| 141 | 140 | if (null === $executeReceiverStrategy) { |
| 142 | 141 | $executeReceiverStrategy = null === $queueConsuming->batchCount ? |
| 143 | - new SimpleExecuteReceiverStrategy() : |
|
| 144 | - new BatchExecuteReceiverStrategy($queueConsuming->batchCount); |
|
| 142 | + new SimpleExecuteReceiverStrategy() : new BatchExecuteReceiverStrategy($queueConsuming->batchCount); |
|
| 145 | 143 | } |
| 146 | 144 | |
| 147 | 145 | $executeReceiverStrategy->setMessagesProccessor(new FnMessagesProcessor( |
| 148 | - (function (array $messages) use ($queueConsuming) { |
|
| 146 | + (function(array $messages) use ($queueConsuming) { |
|
| 149 | 147 | $logAmqpContext = ['queue' => $queueConsuming->queueName]; |
| 150 | 148 | if ($this->getExecuteReceiverStrategy($queueConsuming)->canPrecessMultiMessages()) { |
| 151 | 149 | $logAmqpContext['messages'] = $messages; |
@@ -188,11 +186,11 @@ discard block |
||
| 188 | 186 | $canPrecessMultiMessages = $executeReceiverStrategy->canPrecessMultiMessages(); |
| 189 | 187 | if ($canPrecessMultiMessages) { |
| 190 | 188 | if (!$queueConsuming->receiver instanceof BatchReceiverInterface) { |
| 191 | - throw new \InvalidArgumentException('TODO '. $queueConsuming->queueName); |
|
| 189 | + throw new \InvalidArgumentException('TODO '.$queueConsuming->queueName); |
|
| 192 | 190 | } |
| 193 | 191 | } else { |
| 194 | 192 | if (!$queueConsuming->receiver instanceof ReceiverInterface) { |
| 195 | - throw new \InvalidArgumentException('TODO '. $queueConsuming->queueName); |
|
| 193 | + throw new \InvalidArgumentException('TODO '.$queueConsuming->queueName); |
|
| 196 | 194 | } |
| 197 | 195 | } |
| 198 | 196 | |
@@ -252,7 +250,7 @@ discard block |
||
| 252 | 250 | break; |
| 253 | 251 | } |
| 254 | 252 | } catch (AMQPTimeoutException $e) { |
| 255 | - foreach($this->executeReceiverStrategies as $executeReceiverStrategy) { |
|
| 253 | + foreach ($this->executeReceiverStrategies as $executeReceiverStrategy) { |
|
| 256 | 254 | $executeReceiverStrategy->onCatchTimeout($e); |
| 257 | 255 | } |
| 258 | 256 | $now = new \DateTime(); |
@@ -335,7 +333,7 @@ discard block |
||
| 335 | 333 | |
| 336 | 334 | if (!$queueConsuming->noAck) { |
| 337 | 335 | $messages = array_combine( |
| 338 | - array_map(fn ($message) => $message->getDeliveryTag(), $messages), |
|
| 336 | + array_map(fn($message) => $message->getDeliveryTag(), $messages), |
|
| 339 | 337 | $messages |
| 340 | 338 | ); |
| 341 | 339 | |
@@ -351,9 +349,9 @@ discard block |
||
| 351 | 349 | { |
| 352 | 350 | $executeReceiverStrategy = $this->getExecuteReceiverStrategy($queueConsuming); |
| 353 | 351 | |
| 354 | - $ack = !array_search(fn ($reply) => $reply !== ReceiverInterface::MSG_ACK, $replies, true); |
|
| 352 | + $ack = !array_search(fn($reply) => $reply !== ReceiverInterface::MSG_ACK, $replies, true); |
|
| 355 | 353 | if ($this->multiAck && count($messages) > 1 && $ack) { |
| 356 | - $channels = array_map(fn ($message) => $message->getChannel(), $messages); |
|
| 354 | + $channels = array_map(fn($message) => $message->getChannel(), $messages); |
|
| 357 | 355 | if (count($channels) !== array_unique($channels)) { // all messages have same channel |
| 358 | 356 | throw new InvalidArgumentException('Messages can not be processed as multi ack with different channels'); |
| 359 | 357 | } |
@@ -399,7 +397,7 @@ discard block |
||
| 399 | 397 | 'content_type' => 'text/plain', |
| 400 | 398 | 'correlation_id' => $message->get('correlation_id'), |
| 401 | 399 | ]); |
| 402 | - $message->getChannel()->basic_publish($replayMessage , '', $message->get('reply_to')); |
|
| 400 | + $message->getChannel()->basic_publish($replayMessage, '', $message->get('reply_to')); |
|
| 403 | 401 | } else { |
| 404 | 402 | $this->logger->error('Rpc call send msg to queue which have not rpc reponse', [ |
| 405 | 403 | 'amqp' => ['message' => $message] |
@@ -124,7 +124,7 @@ |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $replices = []; |
| 127 | - foreach($this->messages as $message) { |
|
| 127 | + foreach ($this->messages as $message) { |
|
| 128 | 128 | /** @var AMQPMessage $message */ |
| 129 | 129 | if (!$message->has('correlation_id')) { |
| 130 | 130 | $this->logger->error('unexpected message. rpc replies have no correlation_id '); |