Search in sources :

Example 1 with QueueInterface

use of io.kestra.core.queues.QueueInterface 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();
}
Also used : QueueInterface(io.kestra.core.queues.QueueInterface) KafkaAdminService(io.kestra.runner.kafka.services.KafkaAdminService) SneakyThrows(lombok.SneakyThrows)

Aggregations

QueueInterface (io.kestra.core.queues.QueueInterface)1 KafkaAdminService (io.kestra.runner.kafka.services.KafkaAdminService)1 SneakyThrows (lombok.SneakyThrows)1