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 ?