'How to use Symfony Messenger batch message processing?

Symfony 5.4 added the ability to batch process Messenger messages, but no documentation is available.

Symfony - Handle messages in batches

GitHub PR

How to properly use the new function? Do I need to use a specific stamp when sending a message? Unfortunately, I couldn't find any examples.

$this->eventBus->dispatch(
    (new Envelope(new TaskCreatedEvent($task)))
    ->with(new AckStamp($ack))
);

What should the $ack variable contain? As far as I understand there should be a function. What is her role? I tried passing a static function as the $ack argument, but the handler doesn't buffer the messages, it just processes them.

Symfony has excellent documentation and it is very strange that this function is not documented.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source