th2-conn-dirty-fix (1.0.0)
This microservice allows sending and receiving messages via FIX protocol
Configuration
- sessions - list of session settings
- maxBatchSize - max size of outgoing message batch (
1000
by default) - maxFlushTime - max message batch flush time (
1000
by default) - publishSentEvents - enables/disables publish of "message sent" events (
true
by default) - publishConnectEvents - enables/disables publish of "connect/disconnect" events (
true
by default)
Session settings
- sessionGroup - session group for incoming/outgoing th2 messages (equal to session alias by default)
- sessionAlias - session alias for incoming/outgoing th2 messages
- handler - handler settings
- mangler - mangler settings
Handler settings
- host - service host
- port - service port
- security - connection security settings
- beginString - defines the start of a new message and the protocol version
- heartBtInt - message waiting interval
- senderCompID - ID of the sender of the message
- targetCompID - ID of the message recipient
- defaultApplVerID - specifies the service pack release being applied, by default, to message at the session level
- senderSubID - assigned value used to identify specific message originator (desk, trader, etc.)
- encryptMethod - encryption method
- username - user name
- password - user password. FIX client uses the Password(554) tag for unencrypted mode and the EncryptedPassword(1402) tag for encrypted. The encryption is enabled via passwordEncryptKeyFilePath option.
- newPassword - user new password. FIX client uses the NewPassword(925) tag for unencrypted mode and the NewEncryptedPassword(1404) tag for encrypted. The encryption is enabled via passwordEncryptKeyFilePath option.
- passwordEncryptKeyFilePath - path to key file for encrypting. FIX client encrypts the password value via
RSA
algorithm using specified file if this option is specified. - passwordEncryptKeyFileType - type of key file content. Supported values:
[PEM_PUBLIC_KEY]
. Default value isPEM_PUBLIC_KEY
- passwordKeyEncryptAlgorithm - encrypt algorithm for reading key from file specified in the passwordEncryptKeyFilePath. See the KeyFactory section in the Java Cryptography Architecture Standard Algorithm Name for information about standard algorithm names. Default value is
RSA
- passwordEncryptAlgorithm - encrypt algorithm for encrypting passwords specified in the password and newPassword. See the Cipher section in the Java Cryptography Architecture Standard Algorithm Name for information about standard transformation names. Default value is
RSA
- testRequestDelay - interval for test request
- reconnectDelay - interval for reconnect
- disconnectRequestDelay - the interval for the shutdown request
- resetSeqNumFlag - resetting sequence number in initial Logon message (when conn started)
- resetOnLogon - resetting the sequence number in Logon in other cases (e.g. disconnect)
- loadSequencesFromCradle - defines if sequences will be loaded from cradle to use them in logon message.
- sessionStartTime - UTC time when session starts. (
nullable
) - sessionEndTime - UTC time when session ends. required if startSessionTime is filled.
- useNextExpectedSeqNum - session management based on next expected sequence number. (
false
by default) - saveAdminMessages - defines if admin messages will be saved to internal outgoing buffer. (
false
by default)
Security settings
- ssl - enables SSL on connection (
false
by default) - sni - enables SNI support (
false
by default) - certFile - path to server certificate (
null
by default) - acceptAllCerts - accept all server certificates (
false
by default, takes precedence overcertFile
)
Mangler settings
Mangler is configured by specifying a list of transformations which it will try to apply to outgoing messages.
Each transformation has a list of conditions which message must meet for transformation actions to be applied.
Condition is basically a field value check:
tag: 35
matches: (8|D)
Where tag
is a field tag to match and matches
is a regex pattern for the field value.
Conditions are specified in when
block of transformation definition:
when:
- tag: 35
matches: (8|D)
- tag: 49
matches: SENDER(.*)
Actions describe modifications which will be applied to a message. There are 4 types of actions:
-
set - sets value of an existing field to the specified value:
set: tag: 1 value: new account
-
add - adds new field before or after an existing field:
add: tag: 15 value: USD after: # or before tag: 58 matches: (.*)
-
move - moves an existing field before or after another field:
move: tag: 49 matches: (.*) after: # or before tag: 56 matches: (.*)
-
replace - replaces an existing field with another field:
replace: tag: 64 matches: (.*) with: tag: 63 value: 1
-
remove - removes an existing field:
remove: tag: 110 matches: (.*)
Actions are specified in then
block of transformation definition:
then:
- set:
tag: 1
value: new account
- remove:
tag: 110
matches: (.*)
Transformation can also automatically recalculate length and checksum if any actions were applied.
This is controlled by update-length
and update-checksum
(both true
by default) transformation options.
Full config will be divided into groups of transforms united by rules, each rule will have name
as key and list of transforms. Only one rule can be triggered, after conditions tests triggered rules will be united into specific list and
only one random rule (group of transforms) will be chosen.
rules:
- name: rule-1
transform: [ ... ]
- name: rule-99
transform: [ ... ]
Complete mangler configuration would look something like this:
mangler:
rules:
- name: rule-1
transform:
- when:
- tag: 8
matches: FIXT.1.1
- tag: 35
matches: D
then:
- set:
tag: 1
value: new account
- add:
tag: 15
value: USD
after:
tag: 58
matches: (.*)
update-length: false
- when:
- tag: 8
matches: FIXT.1.1
- tag: 35
matches: 8
then:
- replace:
tag: 64
matches: (.*)
with:
tag: 63
value: 1
- remove:
tag: 110
matches: (.*)
update-checksum: false
Ways to use mangler:
- Rule described in CR: rule will be applied if message passes
when
condition - Rule is described in CR and message contains property
rule-name
: rule with name fromrule-name
property value will be applied to message despite ofwhen
block.
example - rule with name5
that described in CR will be applied:... .setMetadata(MessageMetadata.newBuilder(builder.getMetadata()).putProperties("rule-name", "5").build()) ...
- Rule is described in message
rule-actions
property: rule will be applied to message as described in propertyrule-actions
example - value of tag 44 will be changed toåÅæÆøØ
... .setMetadata(MessageMetadata.newBuilder(builder.getMetadata()).putProperties("rule-actions", "[{\"set\":{\"tag\": 44,\"value\": \"åÅæÆøØ\"}}]").build()) ...
MQ pins
- input queue with
subscribe
,send
andraw
attributes for outgoing messages - output queue with
publish
,first
(for incoming messages) orsecond
(for outgoing messages) andraw
attributes
Deployment via infra-mgr
Here's an example of infra-mgr
config required to deploy this service
apiVersion: th2.exactpro.com/v1
kind: Th2Box
metadata:
name: fix-client
spec:
image-name: ghcr.io/th2-net/th2-conn-dirty-fix
image-version: 1.0.0
type: th2-conn
custom-config:
maxBatchSize: 1000
maxFlushTime: 1000
batchByGroup: true
publishSentEvents: true
publishConnectEvents: true
sessions:
- sessionAlias: client
security:
ssl: false
sni: false
certFile: ${secret_path:cert_secret}
acceptAllCerts: false
host: "<host>"
port: "<port>"
maxMessageRate: 100000
autoReconnect: true
reconnectDelay: 5000
handler:
beginString: FIXT.1.1
heartBtInt: 30
senderCompID: client
targetCompID: FGW
encryptMethod: 0
username: username
password: password
resetSeqNumFlag: false
resetOnLogon: false
testRequestDelay: 60
reconnectDelay": 5
disconnectRequestDelay: 5
mangler:
rules:
- name: rule-1
transform:
- when:
- { tag: 8, matches: FIXT.1.1 }
- { tag: 35, matches: D }
then:
- set: { tag: 1, value: new account }
- add: { tag: 15, valueOneOf: ["USD", "EUR"] }
after: { tag: 58, matches: (.*) }
update-length: false
- when:
- { tag: 8, matches: FIXT.1.1 }
- { tag: 35, matches: 8 }
then:
- replace: { tag: 64, matches: (.*) }
with: { tag: 63, value: 1 }
- remove: { tag: 110, matches: (.*) }
update-checksum: false
pins:
- name: to_data_provider
connection-type: grpc-client
service-class: com.exactpro.th2.dataprovider.grpc.DataProviderService
- name: to_send
connection-type: mq
attributes:
- subscribe
- send
- raw
settings:
storageOnDemand: false
queueLength: 1000
- name: incoming_messages
connection-type: mq
attributes:
- publish
- store
- raw
filters:
- metadata:
- field-name: direction
expected-value: FIRST
operation: EQUAL
- name: outgoing_messages
connection-type: mq
attributes:
- publish
- store
- raw
filters:
- metadata:
- field-name: direction
expected-value: SECOND
operation: EQUAL
extended-settings:
externalBox:
enabled: false
service:
enabled: false
resources:
limits:
memory: 200Mi
cpu: 600m
requests:
memory: 100Mi
cpu: 20m
Changelog
1.0.0
- Bump
conn-dirty-tcp-core
to3.0.0
for books and pages support
0.0.7
- wait for acceptor logout response on close
- load sequences from lwdp
0.0.6
- wait for logout to be sent
0.0.5
- copy messages before putting them into cache
0.0.4
- Session management based on NextExpectedSeqNum field.
- Recovery handling
- outgoing messages are now saved
- if message wasn't saved sequence reset message with gap fill mode flag is sent.
- Session start and Session end configuration to handle sequence reset by exchange schedule.
0.0.3
- Added new password option into settings
- Provided ability to specify encrypt algorithm for reading key from file and encrypting password and new password fields
0.0.2
- Supported the password encryption via
RSA
algorithm.