Skip to content

Commit 7575175

Browse files
committed
Handle exception in performance tool body processing
A long is extracted from the message body to calculate latency but the conversion/reading can fail in case the tool is not the producer of the message. This commit handles the exception in case the processing fails.
1 parent 6400d49 commit 7575175

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/com/rabbitmq/stream/perf/StreamPerfTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,12 @@ public Integer call() throws Exception {
714714
// so we downsample and calculate latency for every x message
715715
// this should not affect the metric much
716716
if (messageCount.incrementAndGet() % 100 == 0) {
717-
metrics.latency(
718-
System.nanoTime() - Utils.readLong(message.getBodyAsBinary()),
719-
TimeUnit.NANOSECONDS);
717+
try {
718+
long time = Utils.readLong(message.getBodyAsBinary());
719+
metrics.latency(System.nanoTime() - time, TimeUnit.NANOSECONDS);
720+
} catch (Exception e) {
721+
// not able to read the body, maybe not a message from the tool
722+
}
720723
metrics.offset(context.offset());
721724
}
722725
});

0 commit comments

Comments
 (0)