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

Expect KafkaOperations instead of KafkaTemplate for AbstractKafkaListenerContainerFactory#setReplyTemplate #3524

Closed
neshkeev opened this issue Sep 30, 2024 · 4 comments

Comments

@neshkeev
Copy link

Expected Behavior

It should be possible to pass an implementation of KafkaOperations instead of KafkaTemplate into KafkaListenerContainerFactory since extending KafkaTemplate might not always be possible (no default constructor).

Current Behavior

Here is a custom implementation of KafkaOperations:

class MyCustomKafkaOperationsImpl implements KafkaOperations<Object, Object> {
    ...
}

Unfortunately, I cannot pass an instance of MyCustomKafkaOperationsImpl inside KafkaListenerContainerFactory:

@Configuration
public class MyConfig {

    public ConcurrentKafkaListenerContainerFactory<Object, Object> containerFactory() {
        var factory = new ConcurrentKafkaListenerContainerFactory();
        factory.setReplyTemplate(new MyCustomKafkaOperationsImpl()); // IMPOSSIBLE
        return factory;
    }
}

Context

Direct extension of KafkaTemplate might be impossible since its constructors requires at least a ProducerFactory object.
I briefly scanned over the code base, I didn't find any places which require KafkaTemplate specific methods, all send operations come from KafkaOperations

@sobychacko
Copy link
Contributor

@neshkeev I think this is a reasonable request (as far as I can see). Would you be open to sending a PR for this? Then, we can review it and make sure that there are no side effects.

neshkeev added a commit to neshkeev/spring-kafka that referenced this issue Sep 30, 2024
…r ReplyTemplate

Fixes: spring-projects#3524

spring-projects#3524

Replacing `KafkaTemplate` with `KafkaOperations` for Container Factories opens more opportunities for developers to configure replying kafka templates since extending `KafkaTemplate` might not always be possible.

Signed-off-by: Nikita Eshkeev <[email protected]>
@neshkeev
Copy link
Author

neshkeev commented Oct 2, 2024

@sobychacko , please approve my PR so it can trigger a build

@artembilan
Copy link
Member

As a project stewarded by US company, we are unable to accept contributions from Russian sources due to US law at this time.

@artembilan artembilan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
@neshkeev
Copy link
Author

@artembilan , I understand, no hard feelings.

Please consider implementing this idea yourself

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

Successfully merging a pull request may close this issue.

3 participants