In my project I have two JMS queues one data Queue and one Business queue. multiple threads reads data from those two queues and submit it to grid of multiple engines. Grid is having multiple engines which may execute tasks in parallel both sync and async manner.
Problem statement : Events from business queue should take priority over data queue on grid.
This problem can be solved many ways but resource utilization shud be optimal and if possible starvation of event in data queue shud not happen.
One easy soln is : Maintain a counter, increment if business event comes and decrement if business event is processed on grid. If data event comes that need to wait till counter reaches to zero (or max number of engines on grid). Sthng can be done to stop starvation.
开发者_Go百科any better soln which utilizes the grid engines optimally also java thread utilization shud be optimal ?
Have you tried this in the reader threads:
while(reading from any queue)
{
while (there are messages in business queue)
{
process a business queue message.
}
process one data queue message.
}
精彩评论