title: Pass BlockingQueue to Spring KafkaListener
body: <p>I'm new to Java, Spring, and Kafka in general. Here is the situation:</p>
  
  <p>I've used @KafkaListener annotations to make a Kafka Consumer that looks like so:</p>
  
  <pre><code>public class Listener {
  
  private ExecutorService executorService;
  private List&lt;Future&gt; futuresThread1 = new ArrayList&lt;&gt;();
  public Listener() {
      Properties appProps = new AppProperties().get();
      this.executorService = Executors.newFixedThreadPool(Integer.parseInt(appProps.getProperty("listenerThreads")));
  }
  //TODO: how can I pass an approp into this annotation?
  @KafkaListener(id = "id0", topics = "bose.cdp.ingest.marge.boseaccount.normalized")
  public void listener(ConsumerRecord&lt;?, ?&gt; record, ArrayBlockingQueue&lt;ConsumerRecord&gt; arrayBlockingQueue) throws InterruptedException, ExecutionException
      {
          futuresThread1.add(executorService.submit(new Runnable() {
                  @Override public void run() {
                      System.out.println(record);
                      arrayBlockingQueue.add(record);
                  }
          }));
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I added a parameter, ArrayBlockingQueue, to the listener, that I'd like for it to add the messages from Kafka to. </p>
  
  <p>The problem I am having is I can't figure out how I actually pass an ArrayBlockingQueue into the listener because Spring is handling the instantiation and running of the listener behind the scenes. </p>
  
  <p>I need this blocking queue so that another object outside of the listener can access the messages and do some work with it. For example, in my main:</p>
  
  <pre><code>@SpringBootApplication
  public class SourceAccountListenerApp {
      public static void main(String[] args) {
          Properties appProps = new AppProperties().get();
          ArrayBlockingQueue&lt;ConsumerRecord&gt; arrayBlockingQueue = new ArrayBlockingQueue&lt;&gt;(
             Integer.parseInt(appProps.getProperty("blockingQueueSize"))
          );
          //TODO: This starts my listener. How do I pass the queue to it?
          SpringApplication.run(SourceAccountListenerApp.class, args);
      }
  }
  </code></pre>