Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ExecutorService Internal queue problem

 
praveen neppalli naga
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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.
 
praveen neppalli naga
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic