Skip to content

Commit

Permalink
Merge pull request #7 from FabianMartin/graceful_max_execution
Browse files Browse the repository at this point in the history
Graceful max execution timeout support added
  • Loading branch information
williamespindola authored Jul 7, 2017
2 parents b55592e + 09de1fa commit 0256fc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ $app->register(new RabbitServiceProvider(), [
'connection' => 'default',
'exchange_options' => ['name' => 'a_exchange','type' => 'topic'],
'queue_options' => ['name' => 'a_queue', 'routing_keys' => ['foo.#']],
'callback' => 'your_consumer_service'
'callback' => 'your_consumer_service',
'graceful_max_execution' => [
'timeout' => 900,
'exit_code' => 10,
],
]
]
]);
Expand Down
10 changes: 10 additions & 0 deletions src/fiunchinho/Silex/Provider/RabbitServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ private function loadConsumers(Container $container)
$consumer->disableAutoSetupFabric();
}

if (array_key_exists('graceful_max_execution', $options)) {
$grace = $options['graceful_max_execution'];
if (array_key_exists('timeout', $grace)) {
$consumer->setGracefulMaxExecutionDateTimeFromSecondsInTheFuture($grace['timeout']);
}
if (array_key_exists('exit_code', $grace)) {
$consumer->setGracefulMaxExecutionTimeoutExitCode($grace['exit_code']);
}
}

$consumers[$name] = $consumer;
}

Expand Down

0 comments on commit 0256fc6

Please sign in to comment.