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 the static basis without additional effect at runtime. The source filter is the
SourceConditionimplementation and can be NULL if you’d like to ignore it.
context filter - dynamic filter, which at the same time can check appliance 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
RuleActionwhich 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 in case when one of several sections are not implemented.
The rule description is a free text description of the rule.
The source condition is a predicate that helps to perform optimization and pre-filtering. It identifies if this rule should be connected to some source endpoint.
If the message rule has NULL as a source filer, it applies to messages from all sources.
An instance of the
EndpointParams class is passed as a parameter for
EndpointParams 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.|
The rule condition is a predicate that identifies if a certain message should be processed by this rule.
The example below demonstrates a filter by the 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.
The table below specifies the
|FIXFieldList||FIX message, if the source provides one.|
|MessageEvent||Original message event.|
Parameters of the source endpoint.
See the table above with available properties.
|Boolean||Specifies not to execute any rules after execution of the current one.|
The rule action defines the actions that will be applied to the messages that correspond to the
The ctx variable here is the same as for