Nothing could be published because I'm the only client that use that queue:
The jndi.properties associated to this test is:
java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = vm:broker:(vm://localhost)?useJmx=false
connectionFactoryNames = connectionFactory, queueConnectionFactory,
topicConnectionFactry
queue.MyQueue = MyQueue
So I create a In memory broker.
TIA,
Paolo.
James.Strachan wrote:
>
> You don't describe how messages get on the queue - could something
> else have published since your queue browser was created?
>
> On 1/19/07, pcasar <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> Using tansacted session I sent ONE message to a queue, then I receive
>> from
>> the same queue and I get the sent message. After the first receive I
>> create
>> a queue browser that tell me that my queue is empty, but if I try to
>> receive
>> once more on the same queue the result is not null!! Why? The queue was
>> empty!
>>
>> Here the code of my test:
>>
>> ---------------------------------
>> public void testMid2Simple() throws JMSException,
>> NotSupportedException,
>> SystemException, RollbackException, HeuristicRollbackException,
>> HeuristicMixedException, NamingException {
>>
>> Context ctx = new InitialContext();
>> Queue q = (Queue)ctx.lookup("MyQueue");
>>
>> ///// SEND MESSAGE //////
>> QueueConnectionFactory factory =
>> (QueueConnectionFactory)ctx.lookup("queueConnectionFactory");
>> QueueConnection mqConn = factory.createQueueConnection();
>>
>> mqConn.start();
>> QueueSession mqQSess = mqConn.createQueueSession(true,
>> 0);
>>
>> // do stuff
>> QueueSender qs = mqQSess.createSender(q);
>> Message m = mqQSess.createTextMessage("Hello!");
>> qs.send(m);
>>
>> mqQSess.commit();
>> mqConn.close();
>>
>> ///// RECEIVE MESSAGE //////
>> mqConn = factory.createQueueConnection();
>> mqQSess = mqConn.createQueueSession(true, 0);
>>
>> QueueReceiver qr = mqQSess.createReceiver(q);
>> mqConn.start();
>> m = qr.receive(2000);
>> if (m == null) {
>> fail();
>> }
>> mqQSess.commit();
>> mqConn.close();
>>
>> ///// BROWSE QUEUE /////
>> mqConn = factory.createQueueConnection();
>> mqQSess = mqConn.createQueueSession(true,
>> Session.AUTO_ACKNOWLEDGE);
>>
>> QueueBrowser qb = mqQSess.createBrowser(q);
>> if (qb.getEnumeration().hasMoreElements()) {
>> for (Enumeration e = qb.getEnumeration();
>> e.hasMoreElements();) {
>> Message ith = (Message)e.nextElement();
>> ith.getJMSMessageID();
>> }
>> fail();
>> }
>>
>> mqQSess.commit();
>> mqConn.close();
>>
>> ///// RE-RECEIVE MESSAGE //////
>> mqConn = factory.createQueueConnection();
>> mqQSess = mqConn.createQueueSession(true,
>> Session.AUTO_ACKNOWLEDGE);
>>
>> qr = mqQSess.createReceiver(q);
>> mqConn.start();
>> m = qr.receive(2000);
>> if (m != null) {
>> fail(); ///FAILS HERE
>> }
>> mqQSess.commit();
>> mqConn.close();
>> }
>> -----------------------------
>>
>> TIA,
>> Paolo.
>> --
>> View this message in context:
>> http://www.nabble.com/Receive-forever-in-transacted-session-tf3039151.html#a8446747
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
--
View this message in context:
http://www.nabble.com/Receive-forever-in-transacted-session-tf3039151.html#a8449004
Sent from the ActiveMQ - User mailing list archive at Nabble.com.