Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Allow to define batch size when using BatchHandlerTrait with getBatchSize() #17942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down