File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes ExecutorService Internal queue problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "ExecutorService Internal queue problem" Watch "ExecutorService Internal queue problem" New topic
Author

ExecutorService Internal queue problem

praveen neppalli naga
Greenhorn

Joined: Feb 27, 2006
Posts: 6
I am running in to a problem with java.util.concurrent.ExecutorService's internal queue.
I have a producer producing messages in to activemq queue and consumer consuming the messages. The consumer uses ExecutosService thread pooling. The consumer submits the consumed job to thread pool, and if all the threads are busy, the job gets queued in the thread pool internal queue. The issue with this is i want to monitor the activemq to see how many are waiting to be processed. I do not want the thread pool to push jobs in in its internal queue. Its very to hard to say which jobs are waiting to be processed as i cannot monitor the thread pools internal queue.

Has anyone encountered such an issue?

Thank you
Praveen
[ November 15, 2006: Message edited by: praveen neppalli naga ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[praveen] :Its very to hard to say which jobs are waiting to be processed as i cannot monitor the thread pools internal queue.

You could use one of the ThreadPoolExecutor constructors that allows you to provide your own BlockingQueue as the pool's work queue. That way you have a reference to the queue, and can call size() to discover how may tasks are in the queue at a given time.


"I'm not back." - Bill Harding, Twister
praveen neppalli naga
Greenhorn

Joined: Feb 27, 2006
Posts: 6
Thanks for the reply Jim,
Ok that will allow me to see the jobs pending in the queue. But i would be happy to see the activemq queue since it is a persistant one and i can look in to a database table to see what jobs are pending. Now wat happens is i look in to the database table for that queue and see its empty which made me assume that everything is processed. But i digged deep to see those jobs sitting in thread pool internal queue.
Just wondering if there will be any way to maintain the unprocessed jobs in activemq rather than threadpool queue.

Praveen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ExecutorService Internal queue problem