title: Stopping ConcurrentMessageListenerContainer in 1.3.5
body: <p>I have one question and more of trying to understand so i can implement it right way. Requirement is to stop the ConcurrentMessageListenerContainer by invoking stop method on container which OOTB iterates for KafkaMessageListenerContainer(based on concurrency defined) and invoke stop for each consumer Thread.</p>
  
  <p>Just FYI, i am on 1.3.5 and i cannot migrate to 2.* due to Spring Boot 1.5.*.</p>
  
  <p>Configuration:
  Let's say i have topic with 5 partitions and concurrency defined as 5 as well. Using Batchlistener so have batch records count =100 for each poll.</p>
  
  <p>Question:
  When we invoke stop on container, it appears internally, it set running false for each KafkaMessageListenerContainer and call wakeup on listenerConsumer.</p>
  
  <pre><code>setRunning(false);
  this.listenerConsumer.consumer.wakeup();
  </code></pre>
  
  <p>During testing what i have observed, by invoking stop on container in separate thread, it does below:</p>
  
  <p>1)It stops listenerConsumer and that's for sure working. No more polling happens after calling stop.
  2)It seems if any listenerConsumer has already polled 100 records, and in middle of processing it completes the execution before stopping.
  is #2 per design that invoking container stop only send wakeup to stop next polling? Because i don't see any handling of below in KafkaMessageListenerContainer.run()</p>
  
  <pre><code>catch (WakeupException e) {
       //Ignore, we're stopping
  }
  </code></pre>
  
  <p>One more thing, even in spring kafka 2.1 version by having ContainerStoppingBatchErrorHandler, it calls same container stop so i guess it's more of my understanding how to handle this scenario..</p>
  
  <p>To conclude, if above is lot more detail, i want to terminate the listenerThread if stop is been invoked from separate thread. I have manual offset commit so replaying of batch is fine.</p>
  
  <p>Hi Gary,</p>
  
  <p>As you suggested to have consumeraware listener, my question is specific to listener been stopped through container. Once container invokes stop, listener thread be it  BatchListner supposed to be interrupted from execution. I know entire poll of records has been received by listener and question is not about loosing offset as ack is at batch level.</p>