Message routing

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

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

.action(msgCtx -> {....})


The rule description is a free text description of the rule.

			// rule description
                "some 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.

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

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

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.


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. 

{ 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 table below specifies the RuleContex  properties:



FIXFieldListFIX message, if the source provides one.


MessageEventOriginal message event.



Parameters of the source endpoint.

See the table above with available properties.


BooleanSpecifies 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 SourceCondition and RuleCondition filters.


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

The ctx variable here is the same as for RuleCondition.