title: Confluent Kafka how to get specific topic metadata without subscribe
body: <p>I use some code for determination difference between read offsets and max values. It needed for inner diagnostics, for example if difference below &quot;base line&quot; value - so, read speed is good.</p>
  <p>Provided code sample works good, but I should to know partition count for topic. And, later get max offset value for each partition in a topic.</p>
  <p>How to get topic metadata without subscribing to a topic?</p>
  <p>Something like: topic &quot;TestTopic&quot; have 4 partitions.</p>
  <pre><code>    public async Task MaxOffsetValues()
      {
          // just for tests
          // ToDo: use config from settings
  
          while (true)
          {
              var topicName = &quot;testTopic&quot;;
              var config = new ConsumerConfig
              {
                  BootstrapServers = &quot;192.168.1.1:9092,192.168.1.2:9092,192.168.1.3:9092&quot;,
                  GroupId = Guid.NewGuid().ToString(),
                  ClientId = Dns.GetHostName(),
                  EnableAutoCommit = false,
              };
  
              using (var consumer = new ConsumerBuilder&lt;Ignore, string&gt;(config).Build())
              {
                  var offsetBorders = consumer.QueryWatermarkOffsets(new TopicPartition(topicName, 0), TimeSpan.FromSeconds(10));
                  _log.Debug($&quot;[Diagnostic] Topic: ({topicName}), Partition: ({0}) Minimal offset: ({offsetBorders.Low}) Maximum offset: ({offsetBorders.High})&quot;);
              }
  
              await Task.Delay(TimeSpan.FromSeconds(60));
          }
      }
  </code></pre>