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

Support Message Batching #936

Closed
jeremydmiller opened this issue Jun 17, 2024 · 5 comments
Closed

Support Message Batching #936

jeremydmiller opened this issue Jun 17, 2024 · 5 comments
Milestone

Comments

@jeremydmiller
Copy link
Member

It comes up often enough.

So if you have a handler like:

public static void Handle(Message[] messages), and you publish await bus.PublishAsync(new Message()), Wolverine does the aggregation for you. Needs to be able to track the success/failure of each message, plus the batched message. For right now, only support this for local queues.

cc @BrianVallelunga

@BrianVallelunga
Copy link

I'll add the comment that I think the aggregation needs to be by Tenant, also.

@jeremydmiller
Copy link
Member Author

Oh, good point

@jeremydmiller jeremydmiller added this to the 3.0 milestone Jun 18, 2024
@jeremydmiller
Copy link
Member Author

Notes

This might be a bit of over-analysis, but there's some hidden complexity to this

  • Do we still store each incoming message as a separate row in the incoming table? There's value in doing that for the
    sake of the idempotency protection. Simpler mechanics in some way if we just start the batched message and go
  • Batching will need to be explicitly configured some how. Control the batch size, buffer time, and whether it's tenanted or not
  • Do you track the attempts at the single message level, or at the batch level? Easier at the batch level
  • Do you persist at the batch level?
  • Should it be strictly ordered, or not? Maybe that's configurable?

Concrete thoughts per endpoint type:

  • W/ Azure Service Bus or AWS SQS listeners, do the batching at the point the message batching is done? Doesn't help if the batching has a delay

Implementation options

  • Special IMessageHandler that just puts the data into a BufferBlock?
  • Special BufferedBatchingQueue and DurableBatchingQueue? So you immediately publish to that special local queue
  • Try to use a special message type that tracks the original envelopes? That would simplify the persistence

@jeremydmiller
Copy link
Member Author

Latest Thoughts

Use two new classes that effectively implement IReceiver & ILocalQueue:

  1. DurableBatchedReceiver
  2. BatchedReceiver (basically Buffered)

Configure batching separately for each message type. Use LocalQueue for the configuration though. Build a separate receiver for each.

If receiving a message from the outside where there's the possibility of batching, use a MaybeBatchingReceiver that can do the splitting. If a listener endpoint has the MessageType set, use the batching queue as the receiver.

@jeremydmiller
Copy link
Member Author

jeremydmiller commented Sep 3, 2024

Punchlist

  • End to end test with durable local queueing
  • End to end test with durable local queueing and multi-tenancy
  • Docs

jeremydmiller added a commit that referenced this issue Sep 3, 2024
Docs on batch messaging

End to end tests with tenancy

First successful end to end of the batching

Can build executor and handler for batched messages

Moved batching around, basic configuration is in place

Minor changes leading up to more batching work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants