Skip to content

Commit 1c73183

Browse files
committed
MC-35903: Refactor place where lock mechanism is used regarding proper lock description
1 parent 19bc5c1 commit 1c73183

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

app/code/Magento/MessageQueue/Console/StartConsumerCommand.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
7979

8080
$singleThread = $input->getOption(self::OPTION_SINGLE_THREAD);
8181

82-
try {
83-
if ($singleThread && !$this->lockManager->lock(md5($consumerName),0)) { //phpcs:ignore
84-
$output->writeln('<error>Consumer with the same name is running</error>');
85-
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
86-
}
87-
88-
$this->appState->setAreaCode($areaCode ?? 'global');
89-
90-
$consumer = $this->consumerFactory->get($consumerName, $batchSize);
91-
$consumer->process($numberOfMessages);
92-
} finally {
93-
if ($singleThread) {
94-
$this->lockManager->unlock(md5($consumerName)); //phpcs:ignore
95-
}
82+
if ($singleThread && !$this->lockManager->lock(md5($consumerName),0)) { //phpcs:ignore
83+
$output->writeln('<error>Consumer with the same name is running</error>');
84+
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
85+
}
86+
87+
$this->appState->setAreaCode($areaCode ?? 'global');
88+
89+
$consumer = $this->consumerFactory->get($consumerName, $batchSize);
90+
$consumer->process($numberOfMessages);
91+
if ($singleThread) {
92+
$this->lockManager->unlock(md5($consumerName)); //phpcs:ignore
9693
}
9794

9895
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;

0 commit comments

Comments
 (0)