<groupId>de.juplo.kafka</groupId>
<artifactId>simple-producer</artifactId>
<name>Super Simple Producer</name>
+ <description>A Simple Producer, programmed with pure Java, that sends messages via Kafka</description>
<version>1.0-SNAPSHOT</version>
<properties>
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ </plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
private final String topic;
private final Producer<String, String> producer;
- private long produced = 0;
private volatile boolean running = true;
private volatile boolean done = false;
+ private long produced = 0;
public ExampleProducer(String broker, String topic, String clientId)
{
try
{
- for (; running ; i++)
+ for (; running; i++)
{
send(Long.toString(i%10), Long.toString(i));
Thread.sleep(500);
}
}
- catch (InterruptedException e) {}
+ catch (Exception e)
+ {
+ log.error("{} - Unexpected error: {}!", id, e.toString());
+ }
finally
{
log.info("{}: Closing the KafkaProducer", id);
long now = System.currentTimeMillis();
log.trace(
- "{} - Queued #{} key={} latency={}ms",
+ "{} - Queued message with key={} latency={}ms",
id,
- value,
record.key(),
now - time
);