20
20
import java .net .URISyntaxException ;
21
21
import java .security .KeyManagementException ;
22
22
import java .security .NoSuchAlgorithmException ;
23
+ import java .time .Duration ;
23
24
import java .util .*;
24
25
import java .util .concurrent .TimeoutException ;
25
26
@@ -632,9 +633,18 @@ public void send(String routingKey, String msg, String eventId)
632
633
: MessageProperties .BASIC ;
633
634
634
635
try {
636
+ long publishStartTime = System .nanoTime ();
635
637
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 );
638
648
if (waitForConfirmsTimeOut == null || waitForConfirmsTimeOut == 0 ) {
639
649
waitForConfirmsTimeOut = DEFAULT_WAIT_FOR_CONFIRMS_TIMEOUT ;
640
650
}
@@ -712,4 +722,4 @@ public String getTypeRoutingKeyFromConfiguration(String eventType) {
712
722
}
713
723
714
724
715
- }
725
+ }
0 commit comments