I'm solving the problem of processing JMS messages with different priority. I use Apache Camel framework as an EIP implementor.I have two queues which I must consume from. The first contains messages with higher priority, the second one messages with lower priority.
Now I'd like to create a special component 'mixer' containing loop doing following steps:
- look in the priority queue
- if it contains a message, it will send it to the output queue and go to the start of a loop (if it contains a lot of messages, it will process the first 10 messages and then go to the step 2)
- if it does not contain any messages, go to the step 2
- look in the second queue
- if it contains a message, send it to the output queue (but ONLY one message) and repeat the loop
- if it does not contain any messages, repeat the loop
As you can see, I would like to keep a special ratio if there will be a lot of messages (10 from priority queue / 1 from the second one). If there is no message in priority queue, we can immediately process the messages in the second queue. I would like to have something like EIP Resequencer that will consume from multiple input queues.
I looked for a Camel's route where I would consume from two queues where I would have a my component "Mixer" described above. I would like to have something like that:
<route>
<from id="A" />
<from id="B" />
<resequence id="mixer" />
<to id="C" />
</route>
But I didn't find a way how to do it. One route can have only one input. If it has more inputs, Camel will internally duplicate the route (we will have two independent routes) and the behavior will be following:
<route>
<from id="A" />
<resequence id="mixer" />
<to id="C" />
</route>
<route>
<from id="B" />
<resequence id="mixer" />
<to id="C" />
</route>
as descibed here. And that is not what I want :-(. Do you have any ideas how to solve my problem? Thanks in advance!