diff --git a/messenger.rst b/messenger.rst index 05427ac651e..367c0e1951e 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2173,14 +2173,26 @@ provided in order to ease the declaration of these special handlers:: } } - // Optionally, you can redefine the `shouldFlush()` method - // of the trait to define your own batch size + // Optionally, you can either redefine the `shouldFlush()` method + // of the trait to define your own batch size... private function shouldFlush(): bool { return 100 <= \count($this->jobs); } + + // ... or redefine the `getBatchSize()` method if the default + // flush behavior suits your needs + private function getBatchSize(): int + { + return 100; + } } +.. versionadded:: 6.3 + + The :method:`Symfony\\Component\\Messenger\\Handler\\BatchHandlerTrait::getBatchSize` + method was introduced 6.3. + .. note:: When the ``$ack`` argument of ``__invoke()`` is ``null``, the message is