use of io.kestra.runner.kafka.services.KafkaAdminService in project kestra by kestra-io.
the class RestoreQueueService method send.
@SneakyThrows
@SuppressWarnings("unchecked")
public <T> int send(List<T> list, String queueName, Class<?> cls, boolean noRecreate) {
Optional<String> queueType = applicationContext.getProperty("kestra.queue.type", String.class);
if (queueType.isPresent() && queueType.get().equals("kafka")) {
KafkaAdminService kafkaAdminService = applicationContext.getBean(KafkaAdminService.class);
if (!noRecreate) {
kafkaAdminService.delete(cls);
}
// need some wait to be sure the topic are deleted before recreated with right configuration
Thread.sleep(2000);
kafkaAdminService.createIfNotExist(cls);
}
QueueInterface<T> queue = (QueueInterface<T>) applicationContext.getBean(QueueInterface.class, Qualifiers.byName(queueName));
list.forEach(queue::emit);
return list.size();
}
Aggregations