You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Adam Brewster (JIRA)" <ji...@apache.org> on 2009/08/30 03:20:15 UTC
[jira] Created: (CAMEL-1962) Seda producer throws if queue is full
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: 2.0.0, 1.6.1
Environment: Java SE 5
Reporter: Adam Brewster
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.
[jira] Commented: (CAMEL-1962) Seda producer throws if queue is
full
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=53914#action_53914 ]
Claus Ibsen commented on CAMEL-1962:
------------------------------------
I think its best to offer an option on the seda endpoint to dictate which behavior you want
- current behavior with an exception
- waiting and blocking
And maybe this one to offer eg a 20 sec timeout
- waiting, blocking but with timeout
> 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.
[jira] Commented: (CAMEL-1962) Seda producer throws if queue is
full
Posted by "Adam Brewster (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=53932#action_53932 ]
Adam Brewster commented on CAMEL-1962:
--------------------------------------
On a third look today, and after reviewing [http://www.eecs.harvard.edu/~mdw/papers/mdw-phdthesis.pdf], I think that it will take more than a few lines to bring this component into line with the SEDA ideas and to get it into a state where it's really useful to me. In particular, I think three critical features are missing:
- SEDA queues are one way. A producer shouldn't wait for a response. If one needs a response, then a direct:// endpoint may be more appropriate. This would cause problems in the VM component, though.
- SEDA components should have admission control over their queue. While limiting the length of the queue is a start, it's not really enough.
- SEDA stages don't necessarily have one output. A stage can deposit work into any number of other queues. Routing from seda:// seems peculiar.
I like the ideas that camel introduces but it's starting to look like integrating it into my current project is going to cause more issues that it solves, so I'm going to put it on the shelf for a bit.
> 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.
[jira] Commented: (CAMEL-1962) Seda producer throws if queue is
full
Posted by "Adam Brewster (JIRA)" <ji...@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.
[jira] Updated: (CAMEL-1962) Seda producer throws if queue is full
Posted by "Adam Brewster (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Adam Brewster updated CAMEL-1962:
---------------------------------
Attachment: 0001-seda-don-t-throw-IllegalStateException.patch
Here's my attempt at a fix.
I know that there are two variables called queue in the new class, but it seemed prettier than casting.
> 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.
[jira] Resolved: (CAMEL-1962) Seda producer throws if queue is full
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-1962.
--------------------------------
Resolution: Won't Fix
Keeping current behavior. Adam is looking for something elsewhere.
> 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.