ARTEMIS-4576 ServerSessionImpl#updateProducerMetrics access large messages after being routed

This commit is contained in:
Howard Gao 2024-01-18 17:31:50 +08:00 committed by Clebert Suconic
parent 3dd50f8ff1
commit 6f6c5723d5
1 changed files with 7 additions and 3 deletions

View File

@ -2357,11 +2357,15 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
routingContext.setAddress(art.getName());
routingContext.setRoutingType(art.getRoutingType());
// Retrieve message size for metrics update before routing,
// since large message backing files may be closed once routing completes
int mSize = msg instanceof LargeServerMessageImpl ? ((LargeServerMessageImpl)msg).getBodyBufferSize() : msg.getEncodeSize();
result = postOffice.route(msg, routingContext, direct);
logger.debug("Routing result for {} = {}", msg, result);
updateProducerMetrics(msg, senderName);
updateProducerMetrics(msg, senderName, mSize);
} finally {
if (!routingContext.isReusable()) {
routingContext.clear();
@ -2520,10 +2524,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
return "ServerSession [id=" + getConnectionID() + ":" + getName() + "]";
}
private void updateProducerMetrics(Message msg, String senderName) {
private void updateProducerMetrics(Message msg, String senderName, int mSize) {
ServerProducer serverProducer = serverProducers.getServerProducer(senderName, msg, this);
if (serverProducer != null) {
serverProducer.updateMetrics(msg.getUserID(), msg instanceof LargeServerMessageImpl ? ((LargeServerMessageImpl)msg).getBodyBufferSize() : msg.getEncodeSize());
serverProducer.updateMetrics(msg.getUserID(), mSize);
}
}