James.Strachan wrote:
> 
> On 1/10/07, JohnRobinson <[EMAIL PROTECTED]> wrote:
>>
>> Hi folks,
>>
>> I'm hoping someone here can help me out.  I've got ActiveMQ setup in
>> JBoss,
>> with two queues, one in and one out.
>>
>> I've got one MDB per queue.
>>
>> I'm using the JCA approach for configuring ActiveMQ in JBoss, and I'm
>> using
>> the VM broker.
>>
>> While I have one outbound queue, and one outbound MDB, each message can
>> go
>> to a different destination, and for a variety of reasons its not feasible
>> to
>> create one queue per concrete destination.
> 
> -I don't understand what that means :). A queue is a concrete destination?
> 
> LOL!  Let me see if I can explain.  When the message arrives at the MDB it
> is dispatched via a SOAP call to one of several different destinations. 
> So I have one outbound queue, one MDB consuming messages from that, and
> when I have a simple case where there is only one destination (and hence
> one group ID) my messages arrive at the destination out of order (each
> message has a sequence number on it).
> 
> I've turned on the logging in AMQ via log4j and I see the messages are
> arriving in the queue in order (it would be difficult for them not to, but
> I thought I should check that).  Additionally, as the MDB processes the
> messages I put a log statement in that does a toString on the MDB and I
> see multiple instances of the MDB running simultaneously.
> 
> The code that sends the message is in a Stateless Session EJB and uses the
> stock JMS apis, not the ActiveMQ apis.  It looks like this:
> 
> .....
> import javax.jms.JMSException;
> import javax.jms.ObjectMessage;
> import javax.jms.Queue;
> import javax.jms.QueueConnection;
> import javax.jms.QueueConnectionFactory;
> import javax.jms.QueueSender;
> import javax.jms.QueueSession;
> ......
>         InitialContext initCtx = new InitialContext();
>         
>        
>         QueueConnectionFactory qcf = (QueueConnectionFactory)
> initCtx.lookup(
>             "java:comp/env/jms/QueueConnectionFactory");
>         
>         QueueConnection qcon = qcf.createQueueConnection();
>         String groupId = internalMessage.getGroupId();
>         QueueSession qsession = qcon.createQueueSession(true, 0);
>       
>         Queue q = (Queue) initCtx.lookup(queueName);
>         QueueSender qsender = qsession.createSender(q);
>         
>         ObjectMessage message = qsession.createObjectMessage();
>         message.setObject((Serializable) internalMessage);
>         
>         message.setStringProperty("JMSXGroupID",groupId);
>         
>         qsender.setTimeToLive(30000);
>         qsender.send(message);
>         qsender.close();
>         qsession.close();
>         qcon.close();
> 
> Messages are sent to the queue as soon as they are ready, in sequence (1,
> 2, 3, 4, etc) but show up at the SOAP destination out of order (1, 4, 3, 2
> for example) which suggests that they are being processed in parallel. 
> The MDB that processes the messages from the queue has a maximum pool size
> of 100.  My understanding is that AMQ should be dispatching all of the
> messages for a single group to a single instance of the MDB, allowing
> other instances to process messages to other groups. 
> 
>> I've been setting the JMSXGroupID on outbound messages but it doesn't
>> appear
>> to be doing any good.  Based on my debug output outbound messages to the
>> same target group are handled by multiple instances of the MDB, so
>> messages
>> to the same destination are handled in parallel, which is not what I
>> expected to see with the JMSXGroupID.  I was expecting to see that
>> messages
>> to different destinations (in different groups) would be handled in
>> parallel, while messages to the same group would be processed serially.
> 
> 
> -Hmm, I wonder if there's some issue with the JCA container and Message
> -Groups. Are you sure you are using the same value of JMSXGroupID and
> -messages are being processed concurrently for the same value?
> 
> The exact same value is being used for the JMSXGroupID every time.  At the
> moment I'm working with a single group.
> 
>> Have I misunderstood the expected behavior of groups, or do I just not
>> have
>> it setup properly?  I haven't done anything special to enable
>> ExclusiveConsumer, but I see groups are mentioned as an extension of
>> that.
>> Does that mean that ActiveMQ has to be configured for ExclusiveConsumer
>> before grouping will work as expected?  If so, how does one do that using
>> the JCA interface, or can one?
> 
> -No - the existence of a JMSXGroupID on a message is enough to enable
> -message groups.
> 
> That's what I thought.
> 
> -I'm wondering if there's some issue with the JCA RA and message
> -groups. You could experiment switching the RA to something like
> -genericjmsra to see if that does any good; or trying switching to the
> -pure JMS client API (rather than MDBs with RAs) to see if that fixes
> -it.
> 
> I can try that, in fact I'm going to see if I can replicate this problem
> in a small testbed.  But ultimately we want the MDBs as the messages are
> transactional.  
> 
> Given that groups are implemented in the broker, does the choice of broker
> matter?   Should I perhaps be using the tcp broker and starting it
> separately?
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Groups-tf2952450.html#a8285161
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to