Routing Rules configuration
This section describes message routing configuration (Groovy rules).
FIX Edge Java provides the
RoutingRule unit as an abstraction for the internal message routing element. FEJ supports pure Java and Groovy implementations for routing rules.
messageRule helps to build a rule for message processing. It requires a few components for its instantiation:
messageRule(String description, SourceCondition sourceCondition, RuleCondition condition, RuleAction action)
description - string with a free text description of the rule
source filter - checks if this rule should be applied to messages from a certain source. This filter was added as an option with the purpose of faster work and process optimization. The filter can be applied on a static basis without additional effects at runtime. The source filter is the
SourceConditionimplementation and can be NULL if you’d like to ignore it.
context filter - dynamic filter that, at the same time, can check the application of this rule depending on the message content and source attributes. The context filter is the
RuleConditionimplementation and can be NULL if you’d like to ignore it.
action - implementation of
RuleActionthat describes the main goal of this rule. It can be transformation, modification or just resending to the required destination.
It is also possible to use the "helper" method when one of the sections is not implemented.
Free text description of the rule.
Source condition is a predicate that helps do optimization and prefiltering. It identifies if this rule should be connected to some source endpoint.
If the message rule has 'null' as the source filer, it applies to messages from all sources.
An instance of the
EndpointParams class is passed as a parameter for
EndpointParams and has the following properties, which can be checked:
|id||String||Unique endpoint name|
|source||Object||Original endpoint parameters, specific to the endpoint|
|targetCompId||String||The assigned value is used to identify a firm that sends data to this endpoint|
|targetLocationId||String||The assigned value is used to identify a specific source location (i.e. geographic location and/or desk, trader)|
|targetSubId||String||The assigned value is used to identify a specific source (desk, trader, etc.)|
|senderCompId||String||The assigned value is used to identify a receiving firm|
|senderLocationId||String||The assigned value is used to identify a unit destination’s location (i.e. geographic location and/or desk, trader)|
|senderSubId||String||The assigned value is used to identify a specific individual or a unit intended to receive messages|
Rule condition is a predicate that identifies if a certain message should be processed by this rule.
The example below demonstrates a filter according to message type. The action section will be called only for Order (D) messages in the example.
RuleCondition receives the
RuleContext object, which includes information about the message source and the message event itself.
RuleContex has the properties:
|FIXFieldList||FIX message, if the source provides one.|
|MessageEvent||Original message event.|
|EndpointParams||Parameters of the source endpoint. See table above with available properties.|
|boolean||Specifies not to execute any rules after execution of the current one.|
Defines the actions that will be applied to the messages that correspond to the SourceCondition and RuleCondition filters.
The ctx variable here is the same as for