Added retry mechanism when doing publishing in unit-test

For Kafka 0.8, retry is needed to account for delay in leader-election inside Kafka.