Skip to content

Commit 8c722e8

Browse files
committed
feature #17942 [Messenger] Allow to define batch size when using BatchHandlerTrait with getBatchSize() (alexandre-daubois)
This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] Allow to define batch size when using `BatchHandlerTrait` with `getBatchSize()` Fixes #17940 Commits ------- 3e633c4 [Messenger] Allow to define batch size when using `BatchHandlerTrait` with `getBatchSize()`
2 parents f6d8add + 3e633c4 commit 8c722e8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

messenger.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,14 +2173,26 @@ provided in order to ease the declaration of these special handlers::
21732173
}
21742174
}
21752175

2176-
// Optionally, you can redefine the `shouldFlush()` method
2177-
// of the trait to define your own batch size
2176+
// Optionally, you can either redefine the `shouldFlush()` method
2177+
// of the trait to define your own batch size...
21782178
private function shouldFlush(): bool
21792179
{
21802180
return 100 <= \count($this->jobs);
21812181
}
2182+
2183+
// ... or redefine the `getBatchSize()` method if the default
2184+
// flush behavior suits your needs
2185+
private function getBatchSize(): int
2186+
{
2187+
return 100;
2188+
}
21822189
}
21832190

2191+
.. versionadded:: 6.3
2192+
2193+
The :method:`Symfony\\Component\\Messenger\\Handler\\BatchHandlerTrait::getBatchSize`
2194+
method was introduced 6.3.
2195+
21842196
.. note::
21852197

21862198
When the ``$ack`` argument of ``__invoke()`` is ``null``, the message is

0 commit comments

Comments
 (0)