title: LinkedBlockingQueue Issue with put operation
body: <p>I will try to describe the issue I'm facing and back it up with some code samples.
  I'm using LinkedBlockingQueue declared as follows:</p>
  
  <pre><code>private BlockingQueue&lt;OutgoingMessage&gt; outgoingMessageQueue = new LinkedBlockingQueue&lt;OutgoingMessage&gt;();
  </code></pre>
  
  <p>OutgoingMessage represents text message to be sent to the customer. It gets in the queue by web service call that prepares it, saves it to database and puts it the queue. Application is deployed on tomcat so this thread a thread from HTTP pool. </p>
  
  <p>I created different thread to process the queue and to do the actual message sending. It runs indefinitely and calls take() method on queue like this:</p>
  
  <pre><code>public void processOutgoingMessageQueue() {
  
               try {
  
  
                      OutgoingMessage outgoingMessage = outgoingMessageQueue.take();
                      logger.debug(MessageFormat.format("Took outgoing message with id = [{0}] from queue", outgoingMessage.getId()));
  
                      this.forwardToCommunicator(outgoingMessage);
               }
               catch (InterruptedException e) {
                       logger.fatal("Interupted while waiting to process outgoing messages ", e);                 }
               catch (Exception e) {
                       exceptionHandler.handle(e);
               }
  
      }
  </code></pre>
  
  <p>Method processOutgoingMessageQueue() is called from thread.</p>
  
  <p>This is functional in a way that messages are put in the queue and later sent regularly but the client side (side that invoked web service method) doesn't get the response immediately after the outgoing message is put in the queue but rather when the thread that takes it from queue finishes it processing. It looks like the thread from the tomcat's HTTP pool is waiting for other thread to finish message processing and then returns web service response to the client. 
  This results in bad user experience as user has to wait for complete process to finish before he can enqueue another message.</p>
  
  <p>Here is a log that shows that message was put in the queue successfully:</p>
  
  <pre><code>[DEBUG] 2012-07-08 23:09:51,707 [http-8080-8] SimpleServiceCommunicatorImpl: Received sendMessage request from serviceId = [3], charginId = [3], text [some text]
  [DEBUG] 2012-07-08 23:09:51,721 [http-8080-8] SimpleServiceCommunicatorImpl: Request verification succeeded, creating outgoing message.
  [INFO ] 2012-07-08 23:09:51,738 [http-8080-8] SimpleMessageCreatorImpl: Created outgoing message with id = [1,366] and payment invoice with id = [1,323]
  [INFO ] 2012-07-08 23:09:51,738 [http-8080-8] Core: Enqueued outgoing message with id = [1,366]
  </code></pre>
  
  <p>This is client side log that shows send message request being performed:</p>
  
  <pre><code>DEBUG 2012-07-08 23:09:51,702 CoreAdapter: Sending message with serviceId = [3], chargingId = [3], text = [some text]
  INFO  2012-07-08 23:10:06,477 SimpleMessageSenderImpl: Created answer with core id = [1,366]
  INFO  2012-07-08 23:10:06,477 SMSChatServiceImpl: Response message with result = 1366 sent to the customer
  </code></pre>
  
  <p>It shows that request returned after aprox 15 seconds from outgoing message was put in the queue, although there was no more work for the thread HTTP 8080-8 to perform.</p>
  
  <p><strong>Update</strong></p>
  
  <p>This is the method that puts outgoing message into the queue:</p>
  
  <pre><code>public void enqueueOutgoingMessage(OutgoingMessage outgoingMessage) {
              try {
                      outgoingMessageQueue.put(outgoingMessage);
                      logger.info(MessageFormat.format("Enqueued outgoing message with id = [{0}]", outgoingMessage.getId()));
              }
              catch (InterruptedException e) {
                      logger.fatal("Interupted while waiting to enqueue outgoing message. ", e);
              }
      }
  </code></pre>
  
  <p>And this is the thread that processes the queue:</p>
  
  <pre><code> // outgoing message queue
              this.outgoingMessageQueueProcessingThread = new Thread(new Runnable() {
  
                      public void run() {
                              while (!stopQueueProcessing) {
                                      Core.this.processOutgoingMessageQueue();
                              }
  
                      }
              });
  
              this.outgoingMessageQueueProcessingThread.start();
  </code></pre>
  
  <p>stopQueueProcessing is a flag that is set to false on app shutdown.</p>
  
  <p>Could this be a known tomcat or a LinkedBlockingQueue issue?</p>
  
  <p>Does anyone have an idea? It more details are needed, I'll be glad to provide it.</p>