title: How to verify the size of partition or Topic in Kafka?
body: <p>I want to verify the partition size before producing the the record in <code>Kafka</code>.</p>
  
  <p>I have a custom partitioned class which gives me exact partition number in which my message is supposed to drop. </p>
  
  <p><strong>Now my requirement is I want to check the size of partition before sending my record.</strong></p>
  
  <pre><code> List&lt;String&gt; users = userService.findAllUsers();
              for (String user : users) {
              String msg = "Hello " + user;
              //Check size here
            producer.send(new ProducerRecord&lt;String, String&gt;(topic, user, msg), new Callback() {
                      public void onCompletion(RecordMetadata metadata, Exception e) {
                          if (e != null) {
                              e.printStackTrace();
                          }
                      }
                  });
  </code></pre>
  
  <p>Is there any way in kafka I can achieve this ?</p>