Skip to content

Commit c7ec058

Browse files
authored
Merge pull request #9 from RonRademaker/configure-max-messages
feature (worker configuration): add config option to define max messages
2 parents 7fb5922 + f0cefb9 commit c7ec058

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

DependencyInjection/Configuration.php

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ protected function addCommands(ArrayNodeDefinition $node)
7373
->children()
7474
->scalarNode('rabbitmq_consumer')->defaultValue('rabbitmq:consumer -m %%1$d %%2$s')->end()
7575
->scalarNode('rabbitmq_multiple_consumer')->defaultValue('rabbitmq:multiple-consumer -m %%1$d %%2$s')->end()
76+
->integerNode('max_messages')->defaultValue('250')->end()
7677
->end()
7778
->end()
7879
->end()

Services/RabbitMqSupervisor.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ public function build()
100100
}
101101

102102
// generate program configuration files for all consumers
103-
$this->generateWorkerConfigurations(array_keys($this->consumers), $this->commands['rabbitmq_consumer']);
103+
$this->generateWorkerConfigurations(array_keys($this->consumers), $this->commands['rabbitmq_consumer'], $this->commands['max_messages']);
104104

105105
// generate program configuration files for all multiple consumers
106-
$this->generateWorkerConfigurations(array_keys($this->multipleConsumers), $this->commands['rabbitmq_multiple_consumer']);
106+
$this->generateWorkerConfigurations(array_keys($this->multipleConsumers), $this->commands['rabbitmq_multiple_consumer'], $this->commands['max_messages']);
107107

108108
// start supervisor and reload configuration
109109
$this->start();
@@ -252,7 +252,7 @@ public function generateSupervisorConfiguration()
252252
);
253253
}
254254

255-
private function generateWorkerConfigurations($names, $command)
255+
private function generateWorkerConfigurations($names, $command, $maxMessages = 250)
256256
{
257257
if (0 === strpos($_SERVER["SCRIPT_FILENAME"], '/')) {
258258
$executablePath = $_SERVER["SCRIPT_FILENAME"];
@@ -266,7 +266,7 @@ private function generateWorkerConfigurations($names, $command)
266266
$name,
267267
array(
268268
'name' => $name,
269-
'command' => sprintf($command, 250, $name),
269+
'command' => sprintf($command, $maxMessages, $name),
270270
'executablePath' => $executablePath,
271271
'workerOutputLog' => $this->paths['worker_output_log_file'],
272272
'workerErrorLog' => $this->paths['worker_error_log_file'],

0 commit comments

Comments
 (0)