Skip to content

Commit 291be7a

Browse files
[TS-2413] Provided ability to disable transformation strategies (#7)
1 parent 28f8e7e commit 291be7a

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# th2-conn-dirty-fix (1.3.0)
1+
# th2-conn-dirty-fix (1.4.0)
22

33
This microservice allows sending and receiving messages via FIX protocol
44

@@ -333,8 +333,13 @@ spec:
333333
memory: 100Mi
334334
cpu: 20m
335335
```
336+
## 1.4.0
337+
338+
* Provided ability to disable transformation strategies: `TRANSFORM_MESSAGE_STRATEGY`, `INVALID_CHECKSUM`, `FAKE_RETRANSMISSION` for raw message types specified in the `disableForMessageTypes` property
339+
336340
## 1.3.0
337341

342+
* Fixed the problem long recovery in case of mixing recovery message with non-recovery messages
338343
* Migrated to th2 gradle plugin `0.1.1`
339344
* Updated:
340345
* bom: `4.6.1`

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release_version=1.3.0
1+
release_version=1.4.0

src/main/java/com/exactpro/th2/FixHandler.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import java.util.Map;
9292
import java.util.Objects;
9393
import java.util.Random;
94+
import java.util.Set;
9495
import java.util.concurrent.CompletableFuture;
9596
import java.util.concurrent.ExecutionException;
9697
import java.util.concurrent.Executors;
@@ -1391,13 +1392,18 @@ private CompletableFuture<MessageID> splitSend(IChannel channel, ByteBuf message
13911392
}
13921393

13931394
// TODO: Add simplified configuration
1394-
private Map<String, String> transformProcessor(
1395+
private void transformProcessor(
13951396
ByteBuf message,
13961397
Map<String, String> metadata
13971398
) {
13981399
FixField msgTypeField = findField(message, MSG_TYPE_TAG, US_ASCII);
13991400
if(msgTypeField == null || msgTypeField.getValue() == null) {
1400-
return null;
1401+
return;
1402+
}
1403+
Set<String> disableForMessageTypes = strategy.getDisableForMessageTypes();
1404+
if (disableForMessageTypes.contains(msgTypeField.getValue())) {
1405+
LOGGER.info("Strategy '{}' is disabled for {} message type", strategy.getType(), msgTypeField.getValue());
1406+
return;
14011407
}
14021408

14031409
TransformMessageConfiguration config = strategy.getTransformMessageConfiguration();
@@ -1406,7 +1412,7 @@ private Map<String, String> transformProcessor(
14061412
if(!msgTypeField.getValue().equals(transformation.getMessageType())) {
14071413
if(!transformation.getAnyMessageType()) {
14081414
config.decreaseCounter();
1409-
return null;
1415+
return;
14101416
}
14111417
}
14121418

@@ -1493,7 +1499,6 @@ private Map<String, String> transformProcessor(
14931499
}
14941500
);
14951501

1496-
return null;
14971502
}
14981503

14991504
private Map<String, String>
@@ -1573,6 +1578,13 @@ private Map<String, String> transformOutgoingMessageStrategy(ByteBuf message, Ma
15731578
private Map<String, String> fakeRetransmissionOutgoingProcessor(ByteBuf message, Map<String, String> metadata) {
15741579
onOutgoingUpdateTag(message, metadata);
15751580

1581+
Set<String> disableForMessageTypes = strategy.getDisableForMessageTypes();
1582+
FixField msgTypeField = findField(message, MSG_TYPE_TAG, US_ASCII);
1583+
if(msgTypeField != null && msgTypeField.getValue() != null && disableForMessageTypes.contains(msgTypeField.getValue())) {
1584+
LOGGER.info("Strategy '{}' is disabled for {} message type", strategy.getType(), msgTypeField.getValue());
1585+
return null;
1586+
}
1587+
15761588
FixField sendingTime = requireNonNull(findField(message, SENDING_TIME_TAG));
15771589
strategy.getState().addMissedMessageToCacheIfCondition(msgSeqNum.get(), message.copy(), x -> true);
15781590

@@ -2239,13 +2251,14 @@ private Consumer<RuleConfiguration> getSetupFunction(RuleConfiguration config) {
22392251
case SEQUENCE_RESET: return this::runReconnectWithSequenceResetStrategy;
22402252
case SEND_SEQUENCE_RESET: return this::sendSequenceReset;
22412253
case TRANSFORM_LOGON: return this::setupTransformStrategy;
2242-
case TRANSFORM_MESSAGE_STRATEGY: return this::setupTransformMessageStrategy;
2254+
case TRANSFORM_MESSAGE_STRATEGY:
2255+
case INVALID_CHECKSUM:
2256+
return this::setupTransformMessageStrategy;
22432257
case CREATE_OUTGOING_GAP: return this::setupOutgoingGapStrategy;
22442258
case PARTIAL_CLIENT_OUTAGE: return this::setupPartialClientOutageStrategy;
22452259
case IGNORE_INCOMING_MESSAGES: return this::setupIgnoreIncomingMessagesStrategy;
22462260
case DISCONNECT_WITH_RECONNECT: return this::setupDisconnectStrategy;
22472261
case FAKE_RETRANSMISSION: return this::setupFakeRetransmissionStrategy;
2248-
case INVALID_CHECKSUM: return this::setupTransformMessageStrategy;
22492262
case LOGON_AFTER_LOGON: return this::runLogonAfterLogonStrategy;
22502263
case POSS_DUP_SESSION_MESSAGES: return this::runPossDupSessionMessages;
22512264
case LOGON_FROM_ANOTHER_CONNECTION: return this::runLogonFromAnotherConnection;

src/main/kotlin/com/exactpro/th2/conn/dirty/fix/brokenconn/configuration/RuleConfiguration.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Exactpro (Exactpro Systems Limited)
2+
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,8 @@ data class RuleConfiguration(
4040
val splitSendConfiguration: SplitSendConfiguration? = null,
4141
val changeSequenceConfiguration: ChangeSequenceConfiguration? = null,
4242
val resendRequestConfiguration: ResendRequestConfiguration? = null,
43-
val sendSequenceResetConfiguration: SendSequenceResetConfiguration? = null
43+
val sendSequenceResetConfiguration: SendSequenceResetConfiguration? = null,
44+
val disableForMessageTypes: Set<String> = setOf("q") // Order Mass Cansel Request (q) message shouldn't be transformed
4445
) {
4546
init {
4647
when(ruleType) {

src/main/kotlin/com/exactpro/th2/conn/dirty/fix/brokenconn/strategy/StatefulStrategy.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class StatefulStrategy(
5050
get() = lock.read { state.config?.missIncomingMessagesConfiguration ?: error("Miss incoming messages config isn't present.") }
5151
val missOutgoingMessagesConfiguration: MissMessageConfiguration
5252
get() = lock.read { state.config?.missOutgoingMessagesConfiguration ?: error("Miss outgoing messages config isn't present.") }
53+
val disableForMessageTypes: Set<String>
54+
get() = lock.read { state.config?.disableForMessageTypes ?: emptySet() }
5355
val transformMessageConfiguration: TransformMessageConfiguration
5456
get() = lock.read { state.config?.transformMessageConfiguration ?: error("Transform message config isn't present.") }
5557
val batchSendConfiguration: BatchSendConfiguration

0 commit comments

Comments
 (0)