mirror of https://github.com/apache/activemq.git
Wait on broker response for async broker commands.
This commit is contained in:
parent
4e23adfcc9
commit
83827f2770
|
@ -90,11 +90,17 @@ public class AmqpReceiver extends AmqpAbstractReceiver {
|
|||
@Override
|
||||
public void close() {
|
||||
if (!isClosed() && isOpened()) {
|
||||
sendToActiveMQ(new RemoveInfo(getProducerId()));
|
||||
}
|
||||
sendToActiveMQ(new RemoveInfo(getProducerId()), new ResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException {
|
||||
AmqpReceiver.super.close();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
||||
//----- Configuration accessors ------------------------------------------//
|
||||
|
||||
|
|
|
@ -118,21 +118,30 @@ public class AmqpSender extends AmqpAbstractLink<Sender> {
|
|||
if (!isClosed() && isOpened()) {
|
||||
RemoveInfo removeCommand = new RemoveInfo(getConsumerId());
|
||||
removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
|
||||
sendToActiveMQ(removeCommand);
|
||||
|
||||
sendToActiveMQ(removeCommand, new ResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException {
|
||||
session.unregisterSender(getConsumerId());
|
||||
AmqpSender.super.detach();
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
super.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (!isClosed() && isOpened()) {
|
||||
RemoveInfo removeCommand = new RemoveInfo(getConsumerId());
|
||||
removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
|
||||
sendToActiveMQ(removeCommand);
|
||||
|
||||
sendToActiveMQ(removeCommand, new ResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException {
|
||||
if (consumerInfo.isDurable()) {
|
||||
RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo();
|
||||
rsi.setConnectionId(session.getConnection().getConnectionId());
|
||||
|
@ -143,10 +152,13 @@ public class AmqpSender extends AmqpAbstractLink<Sender> {
|
|||
}
|
||||
|
||||
session.unregisterSender(getConsumerId());
|
||||
AmqpSender.super.close();
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flow() throws Exception {
|
||||
|
|
|
@ -108,11 +108,15 @@ public class AmqpSession implements AmqpResource {
|
|||
public void close() {
|
||||
LOG.debug("Session {} closed", getSessionId());
|
||||
|
||||
connection.sendToActiveMQ(new RemoveInfo(getSessionId()), new ResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException {
|
||||
getEndpoint().setContext(null);
|
||||
getEndpoint().close();
|
||||
getEndpoint().free();
|
||||
|
||||
connection.sendToActiveMQ(new RemoveInfo(getSessionId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue