title: KafkaConsumer can't poll message, but kafka-console-consumer.sh can work, why?
body: <p>My server install kafka use docker: wurstmeister/kafka.</p>
  
  <p>When I use kafka-clients 2.2.0 to produce and consume kafka message,
  my producer works well, but consumer can't get any message.</p>
  
  <p>but while I use shell, this command can't get message:</p>
  
  <pre><code>/opt/kafka_2.12-2.2.0/bin/kafka-console-consumer.sh --bootstrap-server 10.2.0.242:9092 --topic mytesttopic --from-beginning
  </code></pre>
  
  <p>and this command can get all message:</p>
  
  <pre><code>/opt/kafka_2.12-2.2.0/bin/kafka-console-consumer.sh --bootstrap-server 10.2.0.242:9092 --topic mytesttopic --from-beginning --partition 0
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>String  kafkaServer = "10.2.0.242:9092";
  String defaultTopic = "mytesttopic";
  
  // create topic
  Properties props = new Properties();
  props.put("bootstrap.servers", kafkaServer);
  try (AdminClient client = AdminClient.create(props)) {
      CreateTopicsResult ret = client.createTopics(Arrays.asList(new NewTopic(defaultTopic, 1, (short) 1)));
      ret.all().get();
  }
  
  // send message
  props.put("acks", "all");
  props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  KafkaProducer producer = new KafkaProducer&lt;String, String&gt;(props);
  ProducerRecord&lt;String, String&gt; msg = new ProducerRecord&lt;&gt;(defaultTopic, "a1", "test1");
  Future ret = producer.send(msg);
  System.out.println("send ok： " + ret.get());
  
  // recieve message
  props = new Properties();
  props.put("bootstrap.servers", kafkaServer);
  props.put("group.id", "testaaa4aaa");
  props.put("enable.auto.commit", "false");
  props.put("auto.offset.reset", "earliest");
  props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
  props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
  
  KafkaConsumer consumer = new KafkaConsumer&lt;String, String&gt;(props);
  TopicPartition partition1 = new TopicPartition(defaultTopic, 0);
  consumer.assign(Arrays.asList(partition1));
  //        consumer.subscribe(Arrays.asList(defaultTopic));
  Duration duration = Duration.ofMillis(100);
  while (true) {
      ConsumerRecords&lt;String, String&gt; records = consumer.poll(duration);
  // here always get 0.
      System.out.println(records.count());
  }
  </code></pre>
  
  <p>I tryed set TopicPartition in my code, but still can't get message, can anybody help me?</p>