Skip to content

Commit

Permalink
feat: add KafkaProducer skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
JustKode committed Aug 10, 2023
1 parent f179163 commit fcac3ae
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/justkode/kafka/event/producer/KafkaProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,41 @@
*/
package justkode.kafka.event.producer;

import justkode.kafka.event.producer.worker.ProducerWorker;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


@Slf4j
public class KafkaProducer {
private final static List<ProducerWorker> producerWorkers = new ArrayList<>();

public static void main(String[] args) {
String filePath = System.getProperty("filePath");
String recordsPerSecond = System.getProperty("recordsPerSecond");
String kafkaEndpoint = System.getProperty("kafkaEndpoint");

if (filePath == null) {
throw new RuntimeException("filePath is null. Please fill this parameter");
} else if (recordsPerSecond == null) {
throw new RuntimeException("recordsPerSecond is null. Please fill this parameter");
} else if (kafkaEndpoint == null) {
throw new RuntimeException("kafkaEndpoint is null. Please fill this parameter");
}

log.info("filePath: " + filePath);
log.info("recordsPerSecond: " + recordsPerSecond);
log.info("kafkaEndpoint: " + kafkaEndpoint);
}

static class ShutdownThread extends Thread {
@Override
public void run() {
producerWorkers.forEach(ProducerWorker::shutdown);
}
}
}

0 comments on commit fcac3ae

Please sign in to comment.