package com.example.kafkaapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import com.example.kafkaapp.service.ProducerService;

@SpringBootApplication
public class KafkaApp {
    public static void main(String[] args) throws InterruptedException{
        //SpringApplication.run(KafkaApp.class, args);
        ApplicationContext context = SpringApplication.run(KafkaApp.class, args);
        ProducerService producerService = context.getBean(ProducerService.class);
        System.out.println("Waiting 10 seconds before sending the message...");
        Thread.sleep(10_000);
        System.out.println("ok, sending");
        producerService.sendMessage("test-topic-0", "Hello from main()!");
    }
}