Return-Path: Delivered-To: apmail-camel-dev-archive@www.apache.org Received: (qmail 19187 invoked from network); 30 Aug 2009 17:27:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Aug 2009 17:27:41 -0000 Received: (qmail 94010 invoked by uid 500); 30 Aug 2009 17:27:41 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 93965 invoked by uid 500); 30 Aug 2009 17:27:40 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 93952 invoked by uid 500); 30 Aug 2009 17:27:40 -0000 Delivered-To: apmail-activemq-camel-dev@activemq.apache.org Received: (qmail 93949 invoked by uid 99); 30 Aug 2009 17:27:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Aug 2009 17:27:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Aug 2009 17:27:37 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A733A234C044 for ; Sun, 30 Aug 2009 10:27:16 -0700 (PDT) Message-ID: <845645904.1251653236680.JavaMail.jira@brutus> Date: Sun, 30 Aug 2009 10:27:16 -0700 (PDT) From: "Adam Brewster (JIRA)" To: camel-dev@activemq.apache.org Subject: [jira] Commented: (CAMEL-1962) Seda producer throws if queue is full In-Reply-To: <7125852.1251595215619.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: ae95407df07c98740808b2ef9da0087c X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/CAMEL-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=53895#action_53895 ] Adam Brewster commented on CAMEL-1962: -------------------------------------- It looks like that won't work because SedaProducer overrides the process method to call add anyway {code} queue.add(copy); // lets see if we can get the task done before the timeout boolean done = latch.await(timeout, TimeUnit.MILLISECONDS); if (!done) { exchange.setException(new ExchangeTimedOutException(exchange, timeout)); } {code} and {code} // no wait, eg its a InOnly then just add to queue and return queue.add(copy); {code} ---- The second block can be replaced easily with {code} // no wait, eg its a InOnly then just add to queue and return queue.put(copy); {code} but I'm not sure of the best way to handle this when the caller wants a response. Maybe it's as simple as {code} if (!queue.offer(copy, timeout, TimeUnit.MILLISECONDS)) { exchange.setException(new QueueFullException(exchange)); } else if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { exchange.setException(new ExchangeTimedOutException(exchange, timeout)); } {code} This, however, allows the possibility of waiting twice as long as the timeout (if the the queue accepts the exchange just before the timeout expires latch.await will still wait the full timeout). Another possibility is {code} if (!queue.offer(copy)) { exchange.setException(new QueueFullException(exchange)); } else if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { exchange.setException(new ExchangeTimedOutException(exchange, timeout)); } {code} But it will be confusing when the queue-full behavior depends on the ExchangePatern (InOut drops extra packets, InOnly blocks) > Seda producer throws if queue is full > ------------------------------------- > > Key: CAMEL-1962 > URL: https://issues.apache.org/activemq/browse/CAMEL-1962 > Project: Apache Camel > Issue Type: Bug > Components: camel-core > Affects Versions: 1.6.1, 2.0.0 > Environment: Java SE 5 > Reporter: Adam Brewster > Attachments: 0001-seda-don-t-throw-IllegalStateException.patch > > Original Estimate: 30 minutes > Remaining Estimate: 30 minutes > > The LinkedBlockingQueue used by the SedaComponent supports a couple of different ways to insert an object into the queue. > - Collection.add adds the element immediately if possible or throws an IllegalStateException if the queue is full > - BlockingQueue.offer adds the element immediately if possible or returns false if the queue is full > - BlockingQueue.put waits if necessary and adds the element when space is available > SedaProducer extends CollectionProducer which holds a reference to a collection, so it has to use the add method specified by the Collection interface. > I suggest that either of the BlockingQueue methods would be superior. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.