views:

40

answers:

1

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.

any better soln which utilizes the grid engines optimally also java thread utilization shud be optimal ?

A: 

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.
}


dwb
This is not that straight forward. Here I have mutiple threads which can submit job in sync and async to grid.
If every reader is like I show above, then the business queue will have priority. Maybe you need to explain the situation in more detail. Are the business queue items sync and the data items async?
dwb