Description
Description
When defining a batch consumer with a batch size bigger than current amount of messages in queue, it still flushes the queue no matter what by adding FlushBatchHandlersStamp to the envelope. I need it to wait until the amount of jobs would be greater or equal to my batch size OR flush it every X minutes otherwise. I tried to redeclare flush method like this:
public function flush(bool $force): void
{
if (!$force) {
// Here I was thinking to add an internal timer of some sort
return;
}
if ($jobs = $this->jobs) {
$this->jobs = [];
$this->process($jobs);
}
}
But it doesn't really work, because flush() will not be called unless new message in the queue appears.
Then, according to the docs, "... pending batches are flushed when the worker is stopped.", so I tried to add --time-limit to the consumer call. But in this case I'm just getting this error:
The acknowledger was not called by the "..." batch handler
I'm not completely sure whether this is a bug or expected behavior, but it's clear that messenger component is not able to∂ handle batch messages waiting for the needed amount of messages in the queue.
Am I missing something?
Example
Nothing to add here to be honest. Probably it could be additional methods for the BatchHandlerInterface to define some kind of a timeout before force flush or flag if jobs must be flushed if their amount is less than batch size