activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose MarĂ­a Zaragoza <demablo...@gmail.com>
Subject Re: Selective consuming of priority messages with message groups
Date Thu, 10 Dec 2015 18:18:32 GMT
2015-12-09 13:55 GMT+01:00 frankie_hr <franjo.zemunic@2e-systems.com>:
> 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);
>         }
>

A question about your code:

why do you configure prioritizedMessages= true on your broker and also
use consumers with a selector parameter ?
I guess that to use consumers with a selector parameter is for
avoiding to set prioritizedMessages= true

With prioritizedMessages= true , the broker try to deliver the
messages in order by priority

It's only curiosity

Regards

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

Mime
View raw message