On 6/19/07, jcm231 <[EMAIL PROTECTED]> wrote:



James.Strachan wrote:
>
> On 6/18/07, jcm231 <[EMAIL PROTECTED]> wrote:
>>
>> Hi!
>>
>> I am have a standalone ActiveMQ server and I am sending messages using a
>> producer. The messages include the JMSXGroupID header with two different
>> values: "one" and "two". I launch two Consumer objects, both being
>> threads
>> and implementing the interface MesageListener. The result is that only
>> one
>> of the two consumers receives all the messages. Sometimes is the first
>> consumer and sometimes is the second who receives them all.
>>
>> What am I doing wrong? It is the first time I use ActiveMQ and I would
>> thank
>> any help anybody could give me.
>
> We don't yet guarrentee an exact round-robin dispatch policy on a per
> message group basis; consumers tend to eagerly grab as many messages
> as will fit into their pre-fetch buffer.
> http://activemq.apache.org/what-is-the-prefetch-limit-for.html
>
> to mimick round-robin, try setting the prefetch to 1 on both
> consumers; or try using thousands of messages
>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>


I have sent 34000 messages but they all get consumed by the same consumer.


I tried to specify the prefetchSize as indicated in:

http://activemq.apache.org/what-is-the-prefetch-limit-for.html

but I am not creating the ActiveMQQueue on the consumer's code but on the
xml file. So I put this on my activemq.xml file:


  <!-- Destination -->
  <bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg>

<value>example.MyQueue?consumer.prefetchSize=1;consumer.exclusive=false</value>
    </constructor-arg>
  </bean>

but it seems not be effective.

Creating a queue does nothing, unless you actually use it in your JMS
client (e.g. to consume from)

If you're struggling to set the prefetch groups; try sending say
50,000 messages to group 1, then start mixing 1 and 2; then the first
consumer will get its pre-fetch buffer filled with the first group; so
it won't grab group 2. (Or have lots of groups)

--
James
-------
http://macstrac.blogspot.com/

Reply via email to