mirror of https://github.com/apache/activemq.git
pauses the delivery of messages to the activemq session when a rollback is happening until the message has been redelivered. patch applied with thanks to Tamas Cserveny
This commit is contained in:
parent
af999fe2b2
commit
c9a3202bc3
|
@ -717,7 +717,7 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
if (!closed) {
|
||||
|
||||
try {
|
||||
executor.stop();
|
||||
executor.close();
|
||||
|
||||
for (Iterator<ActiveMQMessageConsumer> iter = consumers.iterator(); iter.hasNext();) {
|
||||
ActiveMQMessageConsumer consumer = iter.next();
|
||||
|
@ -978,11 +978,24 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
for (int i = 0; i < redeliveryCounter; i++) {
|
||||
redeliveryDelay = redeliveryPolicy.getNextRedeliveryDelay(redeliveryDelay);
|
||||
}
|
||||
|
||||
if ( connection.isNonBlockingRedelivery() == false) {
|
||||
LOG.debug("Blocking session until re-delivery...");
|
||||
executor.stop();
|
||||
}
|
||||
|
||||
connection.getScheduler().executeAfterDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
((ActiveMQDispatcher)md.getConsumer()).dispatch(md);
|
||||
|
||||
if (connection.isNonBlockingRedelivery()) {
|
||||
((ActiveMQDispatcher)md.getConsumer()).dispatch(md);
|
||||
} else {
|
||||
LOG.debug("Session released, issuing re-delivery...");
|
||||
executor.executeFirst(md);
|
||||
executor.start();
|
||||
}
|
||||
}
|
||||
}, redeliveryDelay);
|
||||
}
|
||||
|
@ -1016,6 +1029,12 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
if (deliveryListener != null) {
|
||||
deliveryListener.afterDelivery(this, message);
|
||||
}
|
||||
|
||||
try {
|
||||
executor.waitForQueueRestart();
|
||||
} catch (InterruptedException ex) {
|
||||
connection.onClientInternalException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -207,4 +207,15 @@ public class ActiveMQSessionExecutor implements Task {
|
|||
List<MessageDispatch> getUnconsumedMessages() {
|
||||
return messageQueue.removeAll();
|
||||
}
|
||||
|
||||
void waitForQueueRestart() throws InterruptedException {
|
||||
synchronized (messageQueue.getMutex()) {
|
||||
while (messageQueue.isRunning() == false) {
|
||||
if (messageQueue.isClosed()) {
|
||||
break;
|
||||
}
|
||||
messageQueue.getMutex().wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue