mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3262 - queue browser and message order
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1088593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d55a3922c9
commit
1760d1aefb
|
@ -17,6 +17,8 @@
|
|||
package org.apache.activemq.broker.region;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.jms.InvalidSelectorException;
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.ConnectionContext;
|
||||
|
@ -81,4 +83,12 @@ public class QueueBrowserSubscription extends QueueSubscription {
|
|||
checkDone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception {
|
||||
super.remove(context, destination);
|
||||
// there's no unacked messages that needs to be redelivered
|
||||
// in case of browser
|
||||
return new ArrayList<MessageReference>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,4 +187,50 @@ public class JmsQueueBrowserTest extends JmsTestSupport {
|
|||
assertFalse("nothing left in the browser", browserView.hasMoreElements());
|
||||
assertNull("consumer finished", consumer.receiveNoWait());
|
||||
}
|
||||
|
||||
public void testBrowseClose() throws Exception {
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
ActiveMQQueue destination = new ActiveMQQueue("TEST");
|
||||
|
||||
connection.start();
|
||||
|
||||
TextMessage[] outbound = new TextMessage[]{session.createTextMessage("First Message"),
|
||||
session.createTextMessage("Second Message"),
|
||||
session.createTextMessage("Third Message")};
|
||||
|
||||
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
producer.send(outbound[0]);
|
||||
producer.send(outbound[1]);
|
||||
producer.send(outbound[2]);
|
||||
|
||||
|
||||
// create browser first
|
||||
QueueBrowser browser = session.createBrowser((Queue) destination);
|
||||
Enumeration enumeration = browser.getEnumeration();
|
||||
|
||||
|
||||
// browse some messages
|
||||
assertEquals(outbound[0], (Message) enumeration.nextElement());
|
||||
assertEquals(outbound[1], (Message) enumeration.nextElement());
|
||||
//assertEquals(outbound[2], (Message) enumeration.nextElement());
|
||||
|
||||
|
||||
browser.close();
|
||||
|
||||
// create consumer
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
|
||||
// Receive the first message.
|
||||
TextMessage msg = (TextMessage)consumer.receive(1000);
|
||||
assertEquals("Expected " + outbound[0].getText() + " but received " + msg.getText(), outbound[0], msg);
|
||||
msg = (TextMessage)consumer.receive(1000);
|
||||
assertEquals("Expected " + outbound[1].getText() + " but received " + msg.getText(), outbound[1], msg);
|
||||
msg = (TextMessage)consumer.receive(1000);
|
||||
assertEquals("Expected " + outbound[2].getText() + " but received " + msg.getText(), outbound[2], msg);
|
||||
|
||||
consumer.close();
|
||||
producer.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue