Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Do I have to do any work to optimize sending multiple messages. #96

Open
macchmie3 opened this issue Jul 14, 2022 · 4 comments

Comments

@macchmie3
Copy link

Hi, my question is simple - Let's assume I want to send 10000 messages, while being in a message handler already. Can I do optimization in any way? I see no API methods for sending a collection of messages and I was wondering if there are any ways to optimize work in such case. Current code would be something of a sort:

foreach (var message in messages)
{
     await _bus.Send(message);
}

I'm not sure if it helps, but I use SqlServer in leased mode as transport layer.

@macchmie3
Copy link
Author

I have checked with sql profiler that all messages are sent in a single transaction, but are done via single insert operations, is there a way to insert multiple rows in a single db operation?

@mookid8000
Copy link
Member

Not at the moment, no.

But it would definitely be possible for the SQL transport to optimize this, simply by storing messages to be sent in the transaction context, and then do the insertion when committing the message transaction.

@mookid8000 mookid8000 transferred this issue from rebus-org/Rebus Jul 23, 2022
@mookid8000
Copy link
Member

I can take a look at this myself when my summer holiday is over 😎 or if anyone feels like fixing it and submit a PR, I'll be happy to be here with guidance.

@mookid8000
Copy link
Member

I left a half implementation here: https://github.com/rebus-org/Rebus.SqlServer/tree/feature/batching

Will come back to it soon. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants