Improvement proposal for seda-endpoint

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Improvement proposal for seda-endpoint

Ole Andreas Hegle
Hi

I got a problem with a seda-endpoint when I should send more than 1000
messages at a time.

I suggest you create a property value for the maximum queue size (today
this is 1000)

public class SedaComponent extends DefaultComponent {
    public BlockingQueue<Exchange> createQueue() {
              return new LinkedBlockingQueue<Exchange>(1000);
 }


You should also alter the process(Exchange) method in SedaEndpoint from

    queue.add(exchange.copy());

to something like this.

public void process(Exchange exchange) {
            try{
                if(queue.offer(exchange.copy(), 180, TimeUnit.SECONDS))
                    ;
                else
                    System.out.println("Problem, did not find capasity
in queue within 3 minutes");
            }catch(Exception e){
                System.out.println("Error processing exchange "+
e.toString());
            }
        }

This would make it much more reliable.

Regards

Ole Andreas Hegle
Software developer at Businesscape AS

Reply | Threaded
Open this post in threaded view
|

Re: Improvement proposal for seda-endpoint

jstrachan
Sorry for the delay getting to your mail!

On 05/10/2007, Ole Andreas Hegle <[hidden email]> wrote:
> Hi
>
> I got a problem with a seda-endpoint when I should send more than 1000
> messages at a time.
>
> I suggest you create a property value for the maximum queue size (today
> this is 1000)

We should definitely make that configurable.

I've raised a JIRA...
https://issues.apache.org/activemq/browse/CAMEL-230

and just applied a patch so you can now jus use

to("seda:foo?size=2000") etc


(This should apply to both SEDA and VM)


> public class SedaComponent extends DefaultComponent {
>     public BlockingQueue<Exchange> createQueue() {
>               return new LinkedBlockingQueue<Exchange>(1000);
>  }
>
>
> You should also alter the process(Exchange) method in SedaEndpoint from
>
>     queue.add(exchange.copy());
>
> to something like this.
>
> public void process(Exchange exchange) {
>             try{
>                 if(queue.offer(exchange.copy(), 180, TimeUnit.SECONDS))
>                     ;
>                 else
>                     System.out.println("Problem, did not find capasity
> in queue within 3 minutes");
>             }catch(Exception e){
>                 System.out.println("Error processing exchange "+
> e.toString());
>             }
>         }
>
> This would make it much more reliable.

I just want to understand your requirements a little better. Is the
idea you want to fail if you can't send (rather than blocking for the
messages to be consumed)?

I guess we could add a non-blocking mode where a send fails if the
send couldn't be completed immediately? Another option is to use a
non-blocking queue?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com