ARTEMIS-3950: dont prepare unused debug detail during xml data import processing

This commit is contained in:
Robbie Gemmell 2022-08-22 16:10:28 +01:00
parent fb292fde35
commit 734e7f4ae5
1 changed files with 16 additions and 10 deletions

View File

@ -291,11 +291,14 @@ public final class XmlDataImporter extends ActionAbstract {
} }
private void sendMessage(List<String> queues, Message message, File tempFileName) throws Exception { private void sendMessage(List<String> queues, Message message, File tempFileName) throws Exception {
StringBuilder logMessage = new StringBuilder(); final String destination = addressMap.get(queues.get(0));
String destination = addressMap.get(queues.get(0)); final ByteBuffer buffer = ByteBuffer.allocate(queues.size() * 8);
logMessage.append("Sending ").append(message).append(" to address: ").append(destination).append("; routed to queues: "); final boolean debugLog = logger.isDebugEnabled();
ByteBuffer buffer = ByteBuffer.allocate(queues.size() * 8); final StringBuilder debugLogMessage = debugLog ? new StringBuilder() : null;
if (debugLog) {
debugLogMessage.append("Sending ").append(message).append(" to address: ").append(destination).append("; routed to queues: ");
}
for (String queue : queues) { for (String queue : queues) {
long queueID; long queueID;
@ -310,26 +313,29 @@ public final class XmlDataImporter extends ActionAbstract {
ClientMessage managementMessage = managementSession.createMessage(false); ClientMessage managementMessage = managementSession.createMessage(false);
ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queue, "ID"); ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queue, "ID");
managementSession.start(); managementSession.start();
if (logger.isDebugEnabled()) { if (debugLog) {
logger.debug("Requesting ID for: " + queue); logger.debug("Requesting ID for: " + queue);
} }
ClientMessage reply = requestor.request(managementMessage); ClientMessage reply = requestor.request(managementMessage);
Number idObject = (Number) ManagementHelper.getResult(reply); Number idObject = (Number) ManagementHelper.getResult(reply);
queueID = idObject.longValue(); queueID = idObject.longValue();
} }
if (logger.isDebugEnabled()) {
if (debugLog) {
logger.debug("ID for " + queue + " is: " + queueID); logger.debug("ID for " + queue + " is: " + queueID);
} }
queueIDs.put(queue, queueID); // store it so we don't have to look it up every time queueIDs.put(queue, queueID); // store it so we don't have to look it up every time
} }
logMessage.append(queue).append(", ");
buffer.putLong(queueID); buffer.putLong(queueID);
if (debugLog) {
debugLogMessage.append(queue).append(", ");
}
} }
logMessage.delete(logMessage.length() - 2, logMessage.length()); // take off the trailing comma if (debugLog) {
if (logger.isDebugEnabled()) { debugLogMessage.delete(debugLogMessage.length() - 2, debugLogMessage.length()); // take off the trailing comma+space
logger.debug(logMessage); logger.debug(debugLogMessage.toString());
} }
message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array()); message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array());