Page tree
Skip to end of metadata
Go to start of metadata

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  SourceCondition implementation 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 RuleCondition implementation and can be NULL if you’d like to ignore it.

  • action - implementation of RuleAction that 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.

messageRule(description)
.action(msgCtx -> {....})
.build()

RuleDescription

Free text description of the rule.

			// rule description
                "some Rule",

SourceCondition

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.

 			//source filter - apply this rule ponly for session1
              { source -> source.id == "session1" }

An instance of the EndpointParams class is passed as a parameter for SourceConditionEndpointParams and has the following properties, which can be checked: 

PropertyTypeDescription
idStringUnique endpoint name
sourceObjectOriginal endpoint parameters, specific to the endpoint
targetCompIdStringThe assigned value is used to identify a firm that sends data to this endpoint
targetLocationIdStringThe assigned value is used to identify a specific source location (i.e. geographic location and/or desk, trader)
targetSubIdStringThe assigned value is used to identify a specific source (desk, trader, etc.)
senderCompIdStringThe assigned value is used to identify a receiving firm
senderLocationIdStringThe assigned value is used to identify a unit destination’s location (i.e. geographic location and/or desk, trader)
senderSubIdStringThe assigned value is used to identify a specific individual or a unit intended to receive messages

RuleCondition

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. 

{ ctx -> ctx.getMessage().getTagValueAsString(35) == "D" } as RuleCondition

RuleCondition receives the RuleContext object, which includes information about the message source and the message event itself. 

The RuleContex has the properties:

PropertiesTypeDescription

message

FIXFieldListFIX message, if the source provides one.

messageEvent

MessageEventOriginal message event.

sourceParams

EndpointParamsParameters of the source endpoint. See table above with available properties.

exit

booleanSpecifies not to execute any rules after execution of the current one.

RuleAction

Defines the actions that will be applied to the messages that correspond to the SourceCondition and RuleCondition filters. 

Example:

			// action for rule - resend message to all session within same group
            // and stop message processing
                { ctx ->
                    rc.getDestinationsByGroup(ctx.sourceParams.groups).each { adapter ->
                        adapter.send(ctx.message)
                        ctx.exit()
                    }
                } as RuleAction),

The ctx variable here is the same as for RuleCondition.

  • No labels