1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| org.springframework.amqp.rabbit.listener.BlockingQueueConsumer#commitIfNecessary
public boolean commitIfNecessary(boolean localTx) throws IOException {
if (this.deliveryTags.isEmpty()) { return false; }
boolean isLocallyTransacted = localTx || (this.transactional && TransactionSynchronizationManager.getResource(this.connectionFactory) == null); try {
boolean ackRequired = !this.acknowledgeMode.isAutoAck() && !this.acknowledgeMode.isManual();
if (ackRequired && (!this.transactional || isLocallyTransacted)) { long deliveryTag = new ArrayList<Long>(this.deliveryTags).get(this.deliveryTags.size() - 1); this.channel.basicAck(deliveryTag, true); }
if (isLocallyTransacted) { RabbitUtils.commitIfNecessary(this.channel); }
} finally { this.deliveryTags.clear(); }
return true;
}
|