Closed mjwillson closed 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.
OK, cheers!
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.