Skip to content

Commit

Permalink
correctly save affected messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Plotnikov committed Oct 5, 2023
1 parent 43c6050 commit f7f122f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/exactpro/th2/FixHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1464,8 +1464,8 @@ private void runResendRequestStrategy(RuleConfiguration configuration) {
ResendRequestConfiguration resendRequestConfig = configuration.getResendRequestConfiguration();
int msgCount = resendRequestConfig.getMessageCount();
int currentSeq = serverMsgSeqNum.get();
sendResendRequest(currentSeq - msgCount, currentSeq);
try {
sendResendRequest(currentSeq - msgCount, currentSeq);
Thread.sleep(strategy.getState().getConfig().getCleanUpDuration().toMillis());
} catch (Exception e) {
String message = String.format("Error while cleaning up %s strategy", strategy.getType());
Expand Down Expand Up @@ -1818,7 +1818,7 @@ private void ruleEndEvent(RuleType type, Instant start, List<MessageID> messageI
try {
Message jsonBody = createMessageBean(mapper.writeValueAsString(Map.of(
"StartTime", start.toString(), "EndTime", end.toString(),
"Type", type.toString(), "AffectedMessages", messageIDS.stream().map(CommonUtil::getLogId)
"Type", type.toString(), "AffectedMessages", messageIDS.stream().map(CommonUtil::getLogId).collect(Collectors.toList())
)));
Event event = Event
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class StrategyState(val config: RuleConfiguration? = null,
val startTime: Instant = Instant.now()
val type = config?.ruleType ?: RuleType.DEFAULT
private val batchMessageCache: CompositeByteBuf = Unpooled.compositeBuffer()
val messageIDs: MutableList<MessageID> = Collections.synchronizedList(ArrayList<MessageID>())
private val messageIDs: MutableList<MessageID> = ArrayList<MessageID>()

private val lock = ReentrantReadWriteLock()
private var batchMessageCacheSize = 0
Expand Down Expand Up @@ -109,6 +109,10 @@ class StrategyState(val config: RuleConfiguration? = null,
messageID?.let { messageIDs.add(it) }
}

fun getMessageIDs() = lock.read {
ArrayList(messageIDs)
}

companion object {
private const val TOO_BIG_MESSAGE_IDS_LIST = 300;
private val K_LOGGER = KotlinLogging.logger { }
Expand Down

0 comments on commit f7f122f

Please sign in to comment.