title: Why won't my Java consumer read the data that I have created?
body: <p>I am trying to read data from a simple producer that I have made. For some reason whenever I run the consumer, it does not see/produce any of the data I have produced. Can anyone possibly give me any guidance on what to do next?</p>
  
  <p>I have included code of my producer and consumer below:</p>
  
  <p>Producer:</p>
  
  <pre><code>public class AvroProducer {
  
  public static void main(String[] args) {
  
      String bootstrapServers = "localhost:9092";
      String topic = "trackingReportsReceived";
  
      //create Producer properties
      Properties properties = new Properties();
      properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
      properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
      properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName());
      properties.setProperty("schema.registry.url", "http://localhost:8081");
  
      //create the producer
      KafkaProducer&lt;String, trackingReport&gt; producer = new KafkaProducer&lt;&gt;(properties);
  
      //creating my own event
      trackingReport event = trackingReport.newBuilder()
              .setRemoteEventUID(2)
              .setReceivedPacketUID(2)
              .setRemoteUnitAID(2)
              .setEventTime(2)
              .setEventLocationStampUID(3)
              .setEventLatitude(2)
              .setEventLongitude(2)
              .setEventOdometer(3)
              .setEventSpeed(3)
              .setEventCourse(3)
              .build();
  
  
      //create a producer record
      ProducerRecord&lt;String, trackingReport&gt; eventRecord = new ProducerRecord&lt;&gt;(topic, event);
  
      //send data - asynchronous
      producer.send(eventRecord, new Callback() {
          @Override
          public void onCompletion(RecordMetadata recordMetadata, Exception e) {
              if (e == null) {
                      System.out.println("Success!");
                      System.out.println(recordMetadata.toString());
                  } else {
                      e.printStackTrace();
                  }
              }
          });
  
  
      //flush data
      producer.flush();
      //flush and close producer
      producer.close();
  </code></pre>
  
  <p>Consumer:</p>
  
  <pre><code>public class AvroConsumer {
  
  public static void main(String[] args) {
  
      final Logger logger = LoggerFactory.getLogger(AvroConsumer.class);
  
      String bootstrapServers = "localhost:9092";
  
      //create Consumer properties
      Properties properties = new Properties();
      properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
      properties.put(ConsumerConfig.GROUP_ID_CONFIG, "consumer");
      properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
      properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
  
  //        properties.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "1000");
      properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
      properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, KafkaAvroDeserializer.class.getName());
      properties.put("schema.registry.url", "http://localhost:8081");
      properties.put("specific.avro.reader", "true");
  
      //create the consumer
      KafkaConsumer&lt;String, trackingReport&gt; consumer = new KafkaConsumer&lt;&gt;(properties);
      String topic = "trackingReportsReceived";
  
      consumer.subscribe(Collections.singletonList(topic));
  
      System.out.println("Waiting for data...");
  
  //        try {
  
          while (true) {
              ConsumerRecords&lt;String, trackingReport&gt; records = consumer.poll(100);
              for (ConsumerRecord&lt;String, trackingReport&gt; record : records) {
                  trackingReport trackingrep = record.value();
                  System.out.println(trackingrep);
              }
              consumer.commitSync();
          }
  
  //        } catch (Exception e) {
  //            logger.error("Exception occured while consuming messages...", e);
  //        } finally {
  //            consumer.close();
  //        }
  
  
  }
  }
  </code></pre>
  
  <p>N.B. The producer works, however the consumer does not.</p>