mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@698595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
63b2c406a8
commit
efdf8ce25a
|
@ -125,6 +125,8 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
private MessageTransformer transformer;
|
private MessageTransformer transformer;
|
||||||
private boolean clearDispatchList;
|
private boolean clearDispatchList;
|
||||||
|
|
||||||
|
private MessageAck pendingAck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a MessageConsumer
|
* Create a MessageConsumer
|
||||||
*
|
*
|
||||||
|
@ -615,6 +617,8 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
ackCounter = 0;
|
ackCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ack = pendingAck;
|
||||||
}
|
}
|
||||||
if (ack != null) {
|
if (ack != null) {
|
||||||
final MessageAck ackToSend = ack;
|
final MessageAck ackToSend = ack;
|
||||||
|
@ -835,13 +839,19 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
// The delivered message list is only needed for the recover method
|
// The delivered message list is only needed for the recover method
|
||||||
// which is only used with client ack.
|
// which is only used with client ack.
|
||||||
deliveredCounter++;
|
deliveredCounter++;
|
||||||
|
|
||||||
|
MessageAck oldPendingAck = pendingAck;
|
||||||
|
pendingAck = new MessageAck(md, ackType, deliveredCounter);
|
||||||
|
if( oldPendingAck==null ) {
|
||||||
|
pendingAck.setFirstMessageId(pendingAck.getLastMessageId());
|
||||||
|
} else {
|
||||||
|
pendingAck.setFirstMessageId(oldPendingAck.getFirstMessageId());
|
||||||
|
}
|
||||||
|
pendingAck.setTransactionId(session.getTransactionContext().getTransactionId());
|
||||||
|
|
||||||
if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
|
if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
|
||||||
MessageAck ack = new MessageAck(md, ackType, deliveredCounter);
|
session.sendAck(pendingAck);
|
||||||
if( !deliveredMessages.isEmpty() ) {
|
pendingAck=null;
|
||||||
ack.setFirstMessageId(deliveredMessages.getLast().getMessage().getMessageId());
|
|
||||||
}
|
|
||||||
ack.setTransactionId(session.getTransactionContext().getTransactionId());
|
|
||||||
session.sendAck(ack);
|
|
||||||
additionalWindowSize = deliveredCounter;
|
additionalWindowSize = deliveredCounter;
|
||||||
|
|
||||||
// When using DUPS ok, we do a real ack.
|
// When using DUPS ok, we do a real ack.
|
||||||
|
|
|
@ -216,18 +216,8 @@ public abstract class PrefetchSubscription extends AbstractSubscription {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
synchronized(dispatchLock) {
|
synchronized(dispatchLock) {
|
||||||
dequeueCounter++;
|
dequeueCounter++;
|
||||||
node
|
node.getRegionDestination().getDestinationStatistics().getDequeues().increment();
|
||||||
.getRegionDestination()
|
node.getRegionDestination().getDestinationStatistics().getInflight().decrement();
|
||||||
.getDestinationStatistics()
|
|
||||||
.getDequeues()
|
|
||||||
.increment();
|
|
||||||
|
|
||||||
node
|
|
||||||
.getRegionDestination()
|
|
||||||
.getDestinationStatistics()
|
|
||||||
.getInflight()
|
|
||||||
.decrement();
|
|
||||||
|
|
||||||
prefetchExtension--;
|
prefetchExtension--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,6 +226,9 @@ public abstract class PrefetchSubscription extends AbstractSubscription {
|
||||||
// Need to put it back in the front.
|
// Need to put it back in the front.
|
||||||
synchronized(dispatchLock) {
|
synchronized(dispatchLock) {
|
||||||
dispatched.add(0, node);
|
dispatched.add(0, node);
|
||||||
|
// ActiveMQ workaround for AMQ-1730 - Please Ignore next line
|
||||||
|
node.incrementRedeliveryCounter();
|
||||||
|
node.getRegionDestination().getDestinationStatistics().getInflight().decrement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -509,22 +509,21 @@ public class JMSConsumerTest extends JmsTestSupport {
|
||||||
sendMessages(session, destination, 2);
|
sendMessages(session, destination, 2);
|
||||||
session.commit();
|
session.commit();
|
||||||
|
|
||||||
// Only pick up the first message.
|
// The prefetch should fill up with 1 message.
|
||||||
Message message1 = consumer.receive(1000);
|
|
||||||
assertNotNull(message1);
|
|
||||||
|
|
||||||
// Don't acknowledge yet. This should keep our prefetch full.
|
|
||||||
// Since prefetch is still full, the 2nd message should get dispatched
|
// Since prefetch is still full, the 2nd message should get dispatched
|
||||||
// to
|
// to another consumer.. lets create the 2nd consumer test that it does
|
||||||
// another consumer.. lets create the 2nd consumer test that it does
|
|
||||||
// make sure it does.
|
// make sure it does.
|
||||||
ActiveMQConnection connection2 = (ActiveMQConnection)factory.createConnection();
|
ActiveMQConnection connection2 = (ActiveMQConnection)factory.createConnection();
|
||||||
connections.add(connection2);
|
connections.add(connection2);
|
||||||
Session session2 = connection2.createSession(true, 0);
|
Session session2 = connection2.createSession(true, 0);
|
||||||
session2.createConsumer(destination);
|
MessageConsumer consumer2 = session2.createConsumer(destination);
|
||||||
|
|
||||||
// Only pick up the 2nd messages.
|
// Pick up the first message.
|
||||||
Message message2 = consumer.receive(1000);
|
Message message1 = consumer.receive(1000);
|
||||||
|
assertNotNull(message1);
|
||||||
|
|
||||||
|
// Pick up the 2nd messages.
|
||||||
|
Message message2 = consumer2.receive(1000);
|
||||||
assertNotNull(message2);
|
assertNotNull(message2);
|
||||||
|
|
||||||
session.commit();
|
session.commit();
|
||||||
|
|
Loading…
Reference in New Issue