write_kafka: do not call depreciated functions unless necessary