INWTlab / r-kafka

Other
0 stars 0 forks source link

Close producer #14

Open wahani opened 11 months ago

wahani commented 11 months ago

The libkafka implements mostly non blocking API calls. Hence when we open a Producer, with a wrong broker address, we get a valid instance that will begin to spam the logs with failing connection attempts and no way to stop it. Not sure, yet, how to properly access the event API of the lib to build something like a 'status' of the connection to do anything useful. For now it should be at least possible to stop a producer in an interactive session.

If we only want to return 'valid' (an instance that can prove it is capable of producing messages?) producers from the constructor, we may do something like a 'ping' with 'produce' (equivalent to select 1; in SQL) to check liveliness and otherwise close the producer before we return. @aneudecker do you have a suggestion or different idea?

aneudecker commented 11 months ago

I think we do not to produce "ping" messages in a production environment. From the linked issues it seems like all we can do is some kind of statistical measurement for success. More than x% messages delivered -> success, No errors of kind x -> success.

For integration tests this should not be a problem as we can use callbacks / delivery counts / round trips.