git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@748204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-02-26 16:39:40 +00:00
parent 8e6446ffcd
commit f54713a7b3
2 changed files with 39 additions and 2 deletions

View File

@ -287,8 +287,8 @@ public class Queue extends BaseDestination implements Task {
QueueBrowserSubscription browserSubscription = (QueueBrowserSubscription) sub;
// do again in iterate to ensure new messages are dispatched
doPageIn(false);
pageInMessages(false);
synchronized (pagedInMessages) {
if (!pagedInMessages.isEmpty()) {
BrowserDispatch browserDispatch = new BrowserDispatch(browserSubscription, pagedInMessages.values());
@ -1339,6 +1339,10 @@ public class Queue extends BaseDestination implements Task {
Subscription target = null;
int interestCount=0;
for (Subscription s : consumers) {
if (s instanceof QueueBrowserSubscription) {
interestCount++;
continue;
}
if (dispatchSelector.canSelect(s, node)) {
if (!fullConsumers.contains(s)) {
if (!s.isFull()) {

View File

@ -95,4 +95,37 @@ public class JmsQueueBrowserTest extends JmsTestSupport {
consumer.close();
}
public void testBrowseReceive() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQQueue destination = new ActiveMQQueue("TEST");
connection.start();
Message[] outbound = new Message[]{session.createTextMessage("First Message"),
session.createTextMessage("Second Message"),
session.createTextMessage("Third Message")};
MessageProducer producer = session.createProducer(destination);
producer.send(outbound[0]);
// create browser first
QueueBrowser browser = session.createBrowser((Queue) destination);
Enumeration enumeration = browser.getEnumeration();
// create consumer
MessageConsumer consumer = session.createConsumer(destination);
// browse the first message
assertTrue("should have received the fisrts message", enumeration.hasMoreElements());
assertEquals(outbound[0], (Message) enumeration.nextElement());
// Receive the first message.
assertEquals(outbound[0], consumer.receive(1000));
consumer.close();
browser.close();
producer.close();
}
}