Comments (4)
Hey there @michael-forman!
If I understand the lifecycle of bundles etc, doesn't this mean that the topics can't come from Configuration?
It does mean that currently, yes.
Am I missing something by wanting to retrieve the topics from configuration?
No, I think that's reasonable, and it's a bit of an oversight on my part. If you'd like to submit a PR to allow specifying topics via configuration, while maybe allowing topic overrides to still be provided via constructor (for backwards-compatibility), I'd be happy to review it! I'm also happy to set aside some time this weekend to make the change myself if not too.
from dropwizard-kafka.
Hi @mzamani1,
Thanks for the reply.
I'm not sure whether the Topic config belongs in KafkaProducerFactory
class, or elsewhere.
I was looking at (and did in a "fork" of KafkaProducerBundle I made in my project) perhaps adding something like:
public abstract Collection<String> getKafkaTopics(T configuration);
into the KafkaProducerBundle
, similar concept to getKafkaProducerFactory
. The call is late enough in the lifecycle that Configuration is available. The client subclass of KafkaProducerBundle then decides how to get that list - they could still hard code, or get it from config, just without any pre-made configuration class.
The issue with keeping topics in the contstructor, and adding another mechanism to get them is that I'm not sure what the right semantics are if topics were already provided in the constructor and then more/different ones added via that callback. The code could not call getKafkaTopics if there were any topics passed in at construction, or it could add to the existing.
Or there is possibly (probably) a better way entirely to achieve the desired outcome...
I'm happy to PR something like the above. Be the same change for KafkaConsumerBundle
too right? Any thing specific/different/enhanced etc you'd like to see in a PR?
from dropwizard-kafka.
I think we should include a property in the KafkaClientFactory
class, since topics are common to both producers and consumers:
@NotNull
@JsonProperty
private Collection<String> topics = Collections.emptyList();
However, my original reasoning for keeping topics out of configuration is that Producer
s ultimately have to know what messages they should be sending to what topics, and that's not something the factory really handles. The only reason we take topics in the constructor for the KafkaProducerBundle
is to register health checks currently. So it's still going to be up to the user to know what to do with those topics.
The issue with keeping topics in the contstructor, and adding another mechanism to get them is that I'm not sure what the right semantics are if topics were already provided in the constructor and then more/different ones added via that callback. The code could not call getKafkaTopics if there were any topics passed in at construction, or it could add to the existing.
My opinion here would be that we either merge the topics defined in configuration with the topics passed in the constructor, or we prefer the topics defined in the constructor over the configuration values (as a sort of override option).
I'm happy to PR something like the above. Be the same change for KafkaConsumerBundle too right? Any thing specific/different/enhanced etc you'd like to see in a PR?
So Consumers are a bit different, in that after the Consumer
is actually built, I was leaving it up to users to actually call the consumer.subscribe(topics)
method. I'm not totally sold on whether we should do that for a user or not, because there are risks of ConcurrentModificationException
, and it may be that the user wishes to delay subscribing to topics for some reason. Maybe, by default, calling subscribe (but in a protected
method that can be overridden by users).
from dropwizard-kafka.
Hey @michael-forman, is this still something you plan on taking a crack at?
from dropwizard-kafka.
Related Issues (20)
- Create a 1.0.0 release, and get releases and snapshots published via CI. HOT 6
- Add ClusterHealthCheck using AdminClient HOT 4
- Example code illustrating usage HOT 3
- integration tests don't run as part of the build
- Support for schema-based serialization formats HOT 1
- Switch to a semantic versioning scheme? HOT 1
- Topic Management from Configuration HOT 2
- New undocumented constructor for Consumer HOT 1
- Is this ready for GA? HOT 10
- Dependency Dashboard
- Schema registry HOT 1
- Add dropwizard-kafka to Dropwizard modules directory HOT 2
- Add SASL plaintext security configuration HOT 3
- Latest Release tags not working HOT 1
- Releases for Dropwizard 1.3.16, 1.3.17, 2.0? HOT 6
- Kafka Streams? HOT 6
- How to configure Serializer or Deserializers? HOT 2
- Add AdminClient HOT 2
- bundle creation dependency cycle ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropwizard-kafka.