PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] Can symfony messenger handle messages in "bulk"

 March 12, 2022     php, symfony, symfony-messenger     No comments   

Issue

I was wondering, because I can not find anything on symfony or other resources, if php's symfony/messenger can handle messages in "bulk" with any async transport.

For example. Grab 20 messages from the bus, handle those 20 messages, and ack or reject any of the messages.

I know RabbitMQ has a feature to grab n-amount of messages from the queue, and process all of them in a single run. In some cases this will have a better performance over scaling the async workers.

Does anybody have any leads, resources or experience with it? Or am I trying to resolve something by going against the idea of symfony/messenger?

[update]

I'm aware that bulk messages are not part of the (async) messaging concept. That each message should be processed individually. But some message brokers have implemented a feature to "grab" X-amount of messages from a queue and process them (either by sending an acknowledge or rejection, or otherwise). I know handling multiple messages in a single iteration increases complexity of any consumers, but in some cases it will improve performance.

I've used this concept of consuming multiple messages in a single iteration many times, but never with php's symfony/messenger.


Solution

This was not natively possible prior to symfony 5.4.

They added a BatchHandlerInterface which will allow you to batch (and choose the size of the batch) your messages.

You can find more info here :

  • Symfony - Handle messages in batches
  • GitHub PR of the feature


Answered By - Elorfin
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing