MeltwaterArchive / dropwizard-extra

A set of miscellaneous and common Dropwizard utilities
109 stars 45 forks source link

Make KafkaProducer managed by the dropwizard environment's lifecycle #24

Closed mjwillson closed 10 years ago

mjwillson commented 10 years ago

Note I added code to KafkaProducerFactory to register the producer on environment.lifecycle(), just like the consumer factory registers the consumer. This isn't a responsibility I'd normally expect a factory build method to have, but thought it best to stick to the project conventions.

While I was at it I made KafkaProducer's close method into an implementation of Closeable, which doesn't hurt and means it could be used with try-with-resources etc.

Also fixed what appeared to be a typo in the package name for producer.

nicktelford commented 10 years ago

Woops, quite the oversights. You're quite right, on both counts. I've addressed these in dc21341083533a0b159d8980fe1e437f82a78d87

These days, I favour using a separate class to to the lifeycle management (see ManagedProducer), as it allows for better composition. I haven't made this change to the consumer because I didn't want to mess with the API too much until I get around to properly re-writing it.

mjwillson commented 10 years ago

OK, cheers!