ARTEMIS-1535 - settle delivery in same lock as sending the disposition
https://issues.apache.org/jira/browse/ARTEMIS-1535
This commit is contained in:
parent
e129fc795b
commit
34a912b644
|
@ -101,17 +101,29 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object action = ((AmqpValue) msg.getBody()).getValue();
|
Object action = ((AmqpValue) msg.getBody()).getValue();
|
||||||
|
|
||||||
if (action instanceof Declare) {
|
if (action instanceof Declare) {
|
||||||
Binary txID = sessionSPI.newTransaction();
|
Binary txID = sessionSPI.newTransaction();
|
||||||
Declared declared = new Declared();
|
Declared declared = new Declared();
|
||||||
declared.setTxnId(txID);
|
declared.setTxnId(txID);
|
||||||
connection.lock();
|
IOCallback ioAction = new IOCallback() {
|
||||||
try {
|
@Override
|
||||||
delivery.disposition(declared);
|
public void done() {
|
||||||
} finally {
|
connection.lock();
|
||||||
connection.unlock();
|
try {
|
||||||
}
|
delivery.settle();
|
||||||
|
delivery.disposition(declared);
|
||||||
|
} finally {
|
||||||
|
connection.unlock();
|
||||||
|
connection.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int errorCode, String errorMessage) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sessionSPI.afterIO(ioAction);
|
||||||
} else if (action instanceof Discharge) {
|
} else if (action instanceof Discharge) {
|
||||||
Discharge discharge = (Discharge) action;
|
Discharge discharge = (Discharge) action;
|
||||||
|
|
||||||
|
@ -124,9 +136,11 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
|
||||||
public void done() {
|
public void done() {
|
||||||
connection.lock();
|
connection.lock();
|
||||||
try {
|
try {
|
||||||
|
delivery.settle();
|
||||||
delivery.disposition(new Accepted());
|
delivery.disposition(new Accepted());
|
||||||
} finally {
|
} finally {
|
||||||
connection.unlock();
|
connection.unlock();
|
||||||
|
connection.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +162,7 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
|
||||||
log.warn(amqpE.getMessage(), amqpE);
|
log.warn(amqpE.getMessage(), amqpE);
|
||||||
connection.lock();
|
connection.lock();
|
||||||
try {
|
try {
|
||||||
|
delivery.settle();
|
||||||
delivery.disposition(createRejected(amqpE.getAmqpError(), amqpE.getMessage()));
|
delivery.disposition(createRejected(amqpE.getAmqpError(), amqpE.getMessage()));
|
||||||
} finally {
|
} finally {
|
||||||
connection.unlock();
|
connection.unlock();
|
||||||
|
@ -157,29 +172,12 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
|
||||||
log.warn(e.getMessage(), e);
|
log.warn(e.getMessage(), e);
|
||||||
connection.lock();
|
connection.lock();
|
||||||
try {
|
try {
|
||||||
|
delivery.settle();
|
||||||
delivery.disposition(createRejected(Symbol.getSymbol("failed"), e.getMessage()));
|
delivery.disposition(createRejected(Symbol.getSymbol("failed"), e.getMessage()));
|
||||||
} finally {
|
} finally {
|
||||||
connection.unlock();
|
connection.unlock();
|
||||||
}
|
}
|
||||||
connection.flush();
|
connection.flush();
|
||||||
} finally {
|
|
||||||
sessionSPI.afterIO(new IOCallback() {
|
|
||||||
@Override
|
|
||||||
public void done() {
|
|
||||||
connection.lock();
|
|
||||||
try {
|
|
||||||
delivery.settle();
|
|
||||||
} finally {
|
|
||||||
connection.unlock();
|
|
||||||
}
|
|
||||||
connection.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(int errorCode, String errorMessage) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue