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

Skip to content

Conversation

matyo91
Copy link
Contributor

@matyo91 matyo91 commented Mar 28, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #53964 (comment)
License MIT

Key Features

This implementation enables efficient batch processing while taking advantage of the parallel execution capabilities of ParallelMessageBus.

Usage Example

Here's how you would use this trait in a handler class:

class MyParallelBatchHandler
{
    use BatchAsyncHandlerTrait;
    
    public function __construct(ParallelMessageBus $parallelBus)
    {
        $this->setParallelMessageBus($parallelBus);
    }
    
    public function __invoke(MyMessage $message)
    {
        return $this->handle($message, null);
    }
    
    private function process(array $jobs): void
    {
        // This is the fallback implementation that will only be used
        // if ParallelMessageBus is not available/set
        
        // Extract message data
        $data = array_map(fn($job) => $job[0]->getData(), $jobs);
        
        // Perform batch processing
        // ...
        
        // Acknowledge all messages
        foreach ($jobs as [$message, $ack]) {
            $ack->ack();
        }
    }
}

@carsonbot carsonbot added this to the 7.3 milestone Mar 28, 2025
@matyo91 matyo91 force-pushed the messenger-handling-concurrent-messages branch from 97e4cd7 to a571a81 Compare March 28, 2025 22:06
@matyo91 matyo91 force-pushed the messenger-handling-concurrent-messages branch from a571a81 to 29b4e97 Compare March 28, 2025 22:07
@carsonbot carsonbot changed the title Add BatchAsyncHandlerTrait for ParallelMessageBus [Messenger] Add BatchAsyncHandlerTrait for ParallelMessageBus Mar 30, 2025
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants