camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apara <ap...@standardset.com>
Subject Unable to setup route with limit of 30 queue size and 5 processing threads
Date Wed, 29 Apr 2015 23:44:41 GMT
I am trying to build a route at runtime which limits the caller to maximum of
30 objects in a queue, with 5 concurrent processing threads.  I also want
the caller to get an exception when more than 30 objects attempt to be
inserted into the route.

Following this example:
https://code.google.com/p/camelinaction/source/browse/trunk/chapter10/pools/src/test/java/camelinaction/CustomThreadPoolProfileTest.java?spec=svn354&r=354

I created a RouteBuilder and implemented the configure method as:

        makeProfile();

        routeDefinition =
            from(
                routeName
            )
            .threads()
            .executorServiceRef("bigPool")
            .inOnly(
                "direct:single.record.processor"
            );


My makeProfile function is implemented as:

            final ThreadPoolProfile profile = new
ThreadPoolProfile("bigPool");
            profile.setMaxQueueSize(30);
            profile.setPoolSize(5);
            profile.setMaxPoolSize(5);
            profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
           
getContext().getExecutorServiceManager().registerThreadPoolProfile(profile);
            this.threadPoolProfile = profile;

My program runs, and I see multiple threads executing methods, but never at
the same time.  It seems that when one execution ends, the next one starts
on a different thread, but never both in parallel.  Also, my client
inserting records in to the queue never get's an exception when 30 records
are reached.  

Adding some more debug, I see that the client submits request to the end
point and the route executes then the client is allowed to add another
record.  I was hoping that the client would add 30 records at a time and
then either wait or get an exception.

I tried to prefix the names of the endpoints with direct://, vm://, direct:,
vm: but it did not make any differences.  

I am creating a Proxy which I am eventually using to submit requests:

            //Create proxy
            //
            final SingleRecordProcessor
                proxy =
                    new ProxyBuilder(
                        camelContext
                    )
                    .endpoint(
                        builder.getRouteName()
                    )
                    .build(
                        SingleRecordProcessor.class
                    );

Not sure if this is an issue or not.

Not sure what to try next.

Thanks.

-AP_




--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-setup-route-with-limit-of-30-queue-size-and-5-processing-threads-tp5766520.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message