package ru.ibs.socrates.confexporter.external.sdtllmraggateconf.rabbitmq.listener;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import ru.ibs.socrates.confexporter.external.sdtllmraggateconf.rabbitmq.dto.SdtLlmRagGateEventDto;
import ru.ibs.socrates.confexporter.service.content.service.ProcessContentService;


@Configuration(proxyBeanMethods = false)
@Slf4j
@RequiredArgsConstructor
@ConditionalOnProperty(name = "spring.rabbitmq.enabled", havingValue = "true")
public class ContentEventListener {

  private final ProcessContentService processContentService;

  @RabbitListener(queues = "${spring.rabbitmq.queue.name}")
  public void handleMessage(SdtLlmRagGateEventDto event) {
    log.info("Received event: {}", event);
    processContentService.processContent(event);
  }
}
