Skip to content

Commit be307d8

Browse files
authored
REM: Add publishing time to publisher log (#295)
Information message contains information about time needed to communicate with MB. Publishing time has been added to publisher log.
1 parent 4aa72b9 commit be307d8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.net.URISyntaxException;
2121
import java.security.KeyManagementException;
2222
import java.security.NoSuchAlgorithmException;
23+
import java.time.Duration;
2324
import java.util.*;
2425
import java.util.concurrent.TimeoutException;
2526

@@ -632,9 +633,18 @@ public void send(String routingKey, String msg, String eventId)
632633
: MessageProperties.BASIC;
633634

634635
try {
636+
long publishStartTime = System.nanoTime();
635637
channel.basicPublish(exchangeName, routingKey, msgProps, msg.getBytes());
636-
log.info("Published message {} with size {} bytes on exchange '{}' with routing key '{}'", eventId,
637-
msg.getBytes().length, exchangeName, routingKey);
638+
long publishEndTime = System.nanoTime();
639+
long diff = publishEndTime - publishStartTime;
640+
Duration durationInNanos = Duration.ofNanos(diff);
641+
String duration = String.format("%d:%02d:%02d.%03d",
642+
durationInNanos.toHours(),
643+
durationInNanos.toMinutesPart(),
644+
durationInNanos.toSecondsPart(),
645+
durationInNanos.toMillisPart());
646+
log.info("Published message {} with size {} bytes on exchange '{}' with routing key '{}' with the duration of '{}'", eventId,
647+
msg.getBytes().length, exchangeName, routingKey, duration);
638648
if (waitForConfirmsTimeOut == null || waitForConfirmsTimeOut == 0) {
639649
waitForConfirmsTimeOut = DEFAULT_WAIT_FOR_CONFIRMS_TIMEOUT;
640650
}
@@ -712,4 +722,4 @@ public String getTypeRoutingKeyFromConfiguration(String eventType) {
712722
}
713723

714724

715-
}
725+
}

0 commit comments

Comments
 (0)