-
Notifications
You must be signed in to change notification settings - Fork 614
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
Batch-Capable Producer Bindings #2969
Comments
Basically what you are asking (and I agree) is that effectively Consumer batch configuration take precedence over Producer based batch configuration if both present. This makes perfect sense to me. In fact as I am thinking about it. . . the Producer batch configuration would only make sense for cases where you are the source of stream (i.e., Supplier, StreamBridge etc). . . where nothing really coming in (consumed). |
You are right, the proposed design removes the need for batch configuration at the producer. With the proposal, binders could provide 2 producer implementations: IMPL-1: Producer is an accumulator (existing design where a producer has Details regarding IMPL-2:
Binders are free to implement either implementation or both. Producer bindings could
In summary, this is more than giving precedence to consumer binding batch configuration. The proposal attempts to define a new producer binding contract which is complementary to the existing contract. Interestingly, this can technically be implemented by binders today; however, this new contract would need to be defined/documented before implementations can be contributed back. |
@carolmorneau I just pushed a branch with the initial commit of a class that defines |
Thank you @olegz
|
@carolmorneau sorry for late response. Your suggestions seem reasonable so, i should update the branch tomorrow |
@carolmorneau please take a look at the updated version and let me know your thoughts |
@olegz Have you pushed your commit on the |
All done, sorry, made some mistake when pushed it originally - https://github.com/spring-cloud/spring-cloud-stream/tree/GH-2969 |
Thank you @olegz, this looks good to us. This will allow us to standardize on Since this issue is also about getting the proposed design Spring approved, will there eventually be some related documentation updates? For instance, some examples where a producer binding can receive a whole batched message at once and is capable of processing it in a single invocation. |
@carolmorneau Sure, we can eventually update the docs, but we need reference something that is using it and for now our binders do not and I don't see them using it in a forceable future given that the corresponding kafka/rabbit headers are created upstream by the frameworks other then SCST. For now I would like to merge it to main so it can be included in the upcoming RC1 |
Sounds good, this is good to merge |
(Current Batching Pattern) Batch-Accumulator Producer Bindings
Currently, the common batching pattern used by producer bindings is to accumulate messages at the producer binding based on
batchSize
andbatchTimeout
configuration and then bulk send to the target system. In a system where the consumer binding is also operating in batch-mode, this could look like the following:The main challenges with the above are:
batchSize
andbatchTimeout
exist at both bindings and need to be consistent. It is hard to reason about the two timeouts which are independent from each others.(Proposed Enhancement) Batch-Capable Producer Bindings
What if a batch could be delivered to the producer binding as a whole and be handled all at once?
In the above:
batchSize
andbatchTimeout
configuration. It could be a partial batch.Benefits of this design:
batchSize
and nobatchTimeout
to implementWorth noting that this design does not couple the producer binding to the consumer binding. The producer binding benefits from an already accumulated batch by the consumer binding; however, the producer binding remains completely independent from the consumer binding.
Spring Defined Header For Batched Messages
Batched messages already exist in Spring Cloud Stream. Here is a sample batch message which is produced by the Solace consumer binding:
solace_scst_batchedHeaders
holds actual message headers for every message within the batch.Batch messages would benefit from a Spring defined header that is not binder specific. Instead of
solace_scst_batchedHeaders
, a batched message could usescst_batchedHeaders
which would be defined by Spring. This header would standardize the batch message format and would indicate to producer bindings that the message is a batch message and that it should be processed as such.Final Note
Note that the proposed design can be implemented today with no issue, however, it is not a design currently endorsed by Spring. The goal of this issue is to bless this design and provide standards so that it could be implemented in any binders in a consistent manner.
The text was updated successfully, but these errors were encountered: