-
In some specific cases, it may make sense to set/customize the metadata field of the OffsetAndMetadata object with data coming from the consumer. When using Spring Kafka, it's impossible as this object is created internally in KafkaMessageListenerContainer.ListenerConsumer. Due to this, a callback can be set on the container properties but the metadata will always be empty when calling the onComplete method of the callback. This may help having a mechanism to set these metadata. So, the proposal would be to either review the way to set a callback or to simply have an OffsetAndMetadataProvider as follow
This provider would then be set on the container properties as show in the following portion of code
Internally, Spring Kafka would need to be slightly reworked to use the following kind of method instead of directly creating the OffsetAndMetadata object.
Any other way to set metadata is more than welcome. If we agree on the need, I can contribute on the implementation. This one or another one. Thanks for your reply. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Thanks; the example implementation makes it clearer than the SO question. However, I am not sure we want to provide full access to the consumer, just to get the group id. Perhaps we can add some class with useful information... public interface OffsetAndMetadataProvider extends BiFunction<OffsetAndMetadata, ListeneMetadata, OffsetAndMetadata> {
OffsetAndMetadata apply(OffsetAndMetadata oam, ListenerMetadata lm);
}
public class ListenerMetadata {
String groupId;
String listenerId;
...
} We can convert this to a new feature when the discussion is complete; a contribution would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
Discussion can be closed due to #2170 |
Beta Was this translation helpful? Give feedback.
Discussion can be closed due to #2170