From 1a49a9646b6da3f5c983cdb2f43f2d48027956c6 Mon Sep 17 00:00:00 2001 From: Fabian Martin Date: Wed, 5 Jul 2017 22:55:57 +0200 Subject: [PATCH 1/2] graceful_max_execution support added --- .../Silex/Provider/RabbitServiceProvider.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/fiunchinho/Silex/Provider/RabbitServiceProvider.php b/src/fiunchinho/Silex/Provider/RabbitServiceProvider.php index 2667c4f..757afc6 100644 --- a/src/fiunchinho/Silex/Provider/RabbitServiceProvider.php +++ b/src/fiunchinho/Silex/Provider/RabbitServiceProvider.php @@ -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; } From 09de1fa3352930dd8bacdb2d7eaa817ef9b2b906 Mon Sep 17 00:00:00 2001 From: Fabian Martin Date: Wed, 5 Jul 2017 23:38:03 +0200 Subject: [PATCH 2/2] graceful_max_execution added to README --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 909b5da..8ad2cdc 100644 --- a/README.md +++ b/README.md @@ -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, + ], ] ] ]);