activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hackingbear <hackingb...@gmail.com>
Subject Re: Prefetch=0 how to?
Date Wed, 18 Feb 2009 06:25:02 GMT

Thanks, 

I haven't get arround to try this but my test differs from two aspects:
1) I use dedicate session for each consumer
2) I receive from only one consumer twice. There is no problem receiving
from two consumers. But when receiving from one consumer twice, the second
time blocks forever. So the code is more like:

    public void testTwoConsumers() throws Exception {
        Session sessionA = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer1 = sessionA.createConsumer(queue);
        Session sessionB = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer2 = sessionB.createConsumer(queue);

        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

        MessageProducer producer = session.createProducer(queue);
        producer.send(session.createTextMessage("Msg1"));
        producer.send(session.createTextMessage("Msg2"));

        // now lets receive it
        TextMessage answer = (TextMessage)consumer1.receive();
        assertEquals("Should have received a message!", answer.getText(),
"Msg1");
        answer = (TextMessage)consumer1.receive(); // blocked here
        assertEquals("Should have received a message!", answer.getText(),
"Msg2");

//        answer = (TextMessage)consumer2.receiveNoWait();
//        assertNull("Should have not received a message!", answer);
    }


Dejan Bosanac wrote:
> 
> Hi,
> 
> just added a test that tries to reproduce your problem (testTwoConsumers)
> 
> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java?view=markup
> 
> and everything seems to be working fine. Can you try modifying it to
> reproroduce the problem? BTW. What version are you using?
> 
> 
> Cheers
> --
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Sun, Feb 15, 2009 at 1:12 AM, hackingbear <hackingbear@gmail.com>
> wrote:
> 
>>
>> sorry, a small correction:
>>
>>
>> hackingbear wrote:
>> >
>> > - Server 1 receives user message 2, and so try to get a token, get
>> token
>> > B, but get stuck.
>> >
>>
>> I meant:
>>
>> - Server 1 receives user message 2, and so try to get a token, but get
>> stuck. token B never arrives
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Prefetch%3D0-how-to--tp22018602p22018620.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: http://www.nabble.com/Prefetch%3D0-how-to--tp22018602p22072916.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message