First, shouldn't you be expecting thread 2 to consume message 1? Second, I'm guessing you're defining the routes in an XML file, in which case don't you need to encode "<" as "<" and ">" as ">"?
Third, use a JMX viewer such as JConsole to look at the subscriptions on that queue. Find the subscription that isn't working (#1) and see whether it's present and whether its selector looks correct. See whether any messages have been dispatched to it. Fourth, use the web console to browse the queue. Look at the message that isn't getting consumed and see if the headers look correct. Tim On Dec 9, 2015 6:12 AM, "frankie_hr" <franjo.zemu...@2e-systems.com> wrote: > Hi All, > > I'm having issues with a little piece of the code which is supposed to > selectively consume the messages from a queue, using the message priority > as > the selector value. In addition to that, the grouping of messages is also > being used. > > The prioritization policy is defined for the broker: > > PolicyEntry policy = new PolicyEntry(); > policy.setQueue(">"); > policy.setPrioritizedMessages(true); > > The route is as follows: > > > from("jms:queue:test?concurrentConsumers=1&selector=JMSPriority>=4") > .bean(Processor.class, "process") > .to("mock:result"); > > from("jms:queue:test?concurrentConsumers=1&selector=JMSPriority<4") > .bean(Processor.class, "process") > .to("mock:result"); > > The test messages are pushed to the queue as follows: > > List<Message> messagesToSend = new ArrayList<>(); > Message message; > > message = new Message(1); > message.setGroup("1"); > message.setPriority(0); > messagesToSend.add(message); > > message = new Message(2); > message.setGroup("1"); > message.setPriority(9); > messagesToSend.add(message); > > message = new Message(3); > message.setGroup("1"); > message.setPriority(0); > messagesToSend.add(message); > > for (Message messageToSend : messagesToSend) { > > Map<String, Object> headers = new HashMap<String, Object>(); > headers.put(JMS_GROUP_ID_HEADER, messageToSend.getGroup()); > > > headers.put(JMS_PRIORITY_HEADER, messageToSend.getPriority()); > template.sendBodyAndHeaders("jms:queue:test3", messageToSend, > headers); > } > > The behavior I expect is the following: > > - Message 1 is pushed to the queue. > - Message 1 is consumed by the thread #1. > - Message 2 is pushed to the queue. > - Message 2 is consumed by the thread #2 (because of priority based > selector). > - Message 3 is pushed to the queue. > - Message 3 is consumed by the thread #1. > > Instead, the behavior I get is the following: > > - Message 1 is pushed to the queue. > - Message 1 is consumed by the thread #1. > - Message 2 is pushed to the queue. > - Message 2 sits on the queue, not being consumed by any thread. > - Message 3 is pushed to the queue. > - Message 3 is consumed by the thread #1. > > The general overview of the situation is that only the messages matching > the > priority of the first message pushed to the queue will be processed, > regardless of the order they're pushed in, while the messages with priority > falling into the other side of the selector will not be consumed at all and > will stay sitting on the queue. > > The version of AMQ broker I'm using is 5.10. > > So, does this seems to you like a bug or a feature I'm not able to > understand? All input on the topic is highly welcome and appreciated! > > Regards, > Frankie > > > > -- > View this message in context: > http://activemq.2283324.n4.nabble.com/Selective-consuming-of-priority-messages-with-message-groups-tp4704813.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. >