mirror of https://github.com/apache/activemq.git
resolve https://issues.apache.org/activemq/browse/AMQ-2693 - loaded machine with slow thread creation can delay interruption processing past next dispatch which can be problematic. prefetch=1 will workaround
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@933240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc52e42636
commit
9e54516aba
|
@ -144,6 +144,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
|||
private ExecutorService executorService;
|
||||
private MessageTransformer transformer;
|
||||
private boolean clearDispatchList;
|
||||
boolean inProgressClearRequiredFlag;
|
||||
|
||||
private MessageAck pendingAck;
|
||||
private long lastDeliveredSequenceId;
|
||||
|
@ -655,23 +656,32 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
|||
this.session.asyncSendPacket(removeCommand);
|
||||
}
|
||||
|
||||
void clearMessagesInProgress() {
|
||||
void inProgressClearRequired() {
|
||||
inProgressClearRequiredFlag = true;
|
||||
// deal with delivered messages async to avoid lock contention with in progress acks
|
||||
clearDispatchList = true;
|
||||
synchronized (unconsumedMessages.getMutex()) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(getConsumerId() + " clearing dispatched list (" + unconsumedMessages.size() + ") on transport interrupt");
|
||||
}
|
||||
// ensure unconsumed are rolledback up front as they may get redelivered to another consumer
|
||||
List<MessageDispatch> list = unconsumedMessages.removeAll();
|
||||
if (!this.info.isBrowser()) {
|
||||
for (MessageDispatch old : list) {
|
||||
session.connection.rollbackDuplicate(this, old.getMessage());
|
||||
}
|
||||
|
||||
void clearMessagesInProgress() {
|
||||
if (inProgressClearRequiredFlag) {
|
||||
synchronized (unconsumedMessages.getMutex()) {
|
||||
if (inProgressClearRequiredFlag) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(getConsumerId() + " clearing dispatched list (" + unconsumedMessages.size() + ") on transport interrupt");
|
||||
}
|
||||
// ensure unconsumed are rolledback up front as they may get redelivered to another consumer
|
||||
List<MessageDispatch> list = unconsumedMessages.removeAll();
|
||||
if (!this.info.isBrowser()) {
|
||||
for (MessageDispatch old : list) {
|
||||
session.connection.rollbackDuplicate(this, old.getMessage());
|
||||
}
|
||||
}
|
||||
// allow dispatch on this connection to resume
|
||||
session.connection.transportInterruptionProcessingComplete();
|
||||
inProgressClearRequiredFlag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// allow dispatch on this connection to resume
|
||||
session.connection.transportInterruptionProcessingComplete();
|
||||
}
|
||||
|
||||
void deliverAcks() {
|
||||
|
@ -1192,6 +1202,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
|||
public void dispatch(MessageDispatch md) {
|
||||
MessageListener listener = this.messageListener.get();
|
||||
try {
|
||||
clearMessagesInProgress();
|
||||
clearDispatchList();
|
||||
synchronized (unconsumedMessages.getMutex()) {
|
||||
if (!unconsumedMessages.isClosed()) {
|
||||
|
|
|
@ -649,6 +649,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
// connection.transportInterruptionProcessingComplete()
|
||||
//
|
||||
for (final ActiveMQMessageConsumer consumer : consumers) {
|
||||
consumer.inProgressClearRequired();
|
||||
scheduler.executeAfterDelay(new Runnable() {
|
||||
public void run() {
|
||||
consumer.clearMessagesInProgress();
|
||||
|
|
Loading…
Reference in New Issue