package org.distributed;

import java.util.Properties;
import org.apache.kafka.clients.producer.*;

public class Producer {
    public static void main(String[] args) {

        // Kafka configuration properties
        Properties props = new Properties();
        props.put(Tag.SERVER.label, Tag.SERVER_URL.label);
        props.put(Tag.SERIALISER_KEY.label, Tag.SERIALISER.label);
        props.put(Tag.SERIALISER_VAL.label, Tag.SERIALISER.label);

        // Creating KafkaProducer instance
        KafkaProducer<Object, Object> producer = new KafkaProducer<>(props);

        // Topic and message that we want to send
        String message = "Hello, Nerds Welcome to Kafka!";

        // Sending our message to Kafka topic
        producer.send(new ProducerRecord<>(Tag.TOPIC.label, message));

        // Closing the producer
        producer.close();
    }

}
