Skip to content

Commit ed033c3

Browse files
Optimize removing the currently processing message from memory
1 parent ce2a0fe commit ed033c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

console-framework-client/src/main/java/io/axoniq/console/framework/eventprocessor/metrics/ProcessorMetricsRegistry.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.axoniq.console.framework.eventprocessor.metrics
1818

1919
import io.axoniq.console.framework.computeIfAbsentWithRetry
20+
import org.axonframework.messaging.unitofwork.BatchingUnitOfWork
2021
import org.axonframework.messaging.unitofwork.CurrentUnitOfWork
2122
import java.time.Clock
2223
import java.time.Instant
@@ -45,9 +46,12 @@ class ProcessorMetricsRegistry {
4546
processingMessageTimestampsForSegment[segment] = messageTimestamp
4647
return action()
4748
} finally {
48-
CurrentUnitOfWork.get().afterCommit {
49-
getProcessingLatencySegmentMap(processor)
50-
.remove(segment)
49+
val uow = CurrentUnitOfWork.get()
50+
if(uow !is BatchingUnitOfWork || uow.isFirstMessage) {
51+
uow.afterCommit {
52+
getProcessingLatencySegmentMap(processor)
53+
.remove(segment)
54+
}
5155
}
5256
}
5357
}

0 commit comments

Comments
 (0)