Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section describes Groovy message routing and event processing rules.

...

There is a static class with methods that are named "helpers". These methods help an end-user make logic shorter by encapsulating details inside the methods.

NameDefinitionDescription
generateUniqueIdString generateUniqueId()

Returns UUID that is generated using a cryptographically strong pseudo-random number generator.

Example:

def id = generateUniqueId()
stringValueString stringValue(FIXFieldList msg, int tag)

Returns a string representation of the value provided by the tag.

Example:

def destination = stringValue(msg, Header.DeliverToCompID)
messageRule

RoutingRule messageRule(String description, SourceCondition sourceCondition, RuleCondition condition, RuleAction action)

Short version for creating MessageRoutingRule.

messageRule

RoutingRuleBuilder messageRule(String description)


Rule builder for creating MessageRoutingRule.

messageRule(description)
.sourceCondition(params -> {....})
.condition(msgCtx -> {....})
.action(msgCtx -> {....})
.build()
eventRule

EventRoutingRuleBuilder eventRule(String description)


Rule builder for creating EventRoutingRule.

eventRule(description)
.eventType(eventType)
.condition(event -> {....})
.action(event -> {....})
.build()
eventRuleRoutingRule eventRule(String description, Class<AppEvent> eventType,
Predicate<AppEvent> ruleCondition, Consumer<AppEvent> ruleAction)

Short version for creating EventRoutingRule.

removeRepGroupvoid removeRepGroup(FIXFieldList msg, int leadingTag, int groupTags[])

Removes the list of tags that corresponds to the repeating group. 

Example:

removeRepGroup(msg, 453, [452, 448, 447])
sendvoid send(RoutingContext rc, RuleContext ruleContext, String targetCompId)

Sends a message to the session by the provided targetCompId.

Example:

send(routingContext, msgCtx, destination)
sendvoid send(RoutingContext rc, RuleContext ruleContext, String targetCompId, String qualifier)

Sends a message to the session by the provided targetCompId and sessionQualifier.

Example:

send(routingContext, ctx, destination, qualifier)

...

It is not necessary to import classes directly in the groovy.rules file. Imported classes are described in the  sysconf/fej-routing.xml. The values below are predefined and can be extended by custom ones so not to specify imports in the rules.

Code Block
languagexml
titlesysconf/fej-routing.xml
collapsetrue
	<util:list id="imports" value-type="java.lang.String">
        <value>com.epam.fej.context.Storage</value>
        <value>com.epam.fej.context.StorageManager</value>
        <value>com.epam.fej.routing.RoutingContext</value>
        <value>com.epam.fej.routing.MessageEventPool</value>
        <value>com.epam.fej.routing.rules.RoutingRule</value>
        <value>com.epam.fej.routing.rules.RuleAction</value>
        <value>com.epam.fej.routing.rules.RuleCondition</value>
        <value>com.epam.fej.routing.rules.SourceCondition</value>
        <value>com.epam.fej.server.fix.event.FIXSessionStateEvent</value>
        <value>com.epam.fej.server.fix.event.NewSessionEvent</value>
        <value>com.epam.fej.routing.event.RuleErrorEvent</value>
        <value>com.epam.fej.scheduling.event.SchedulerEvent</value>
        <value>com.epam.fej.server.fix.event.ServerStateEvent</value>
        <value>com.epam.fej.routing.endpoint.snf.events.SnFEvent</value>
        <value>com.epam.fej.routing.event.UnprocessedMessageEvent</value>
    </util:list>

...

Code Block
languagexml
titlesysconf/fej-routing.xml
collapsetrue
<property name="additionalProperties">
	<map key-type="java.lang.String">
    	<entry key="routingContext" value-ref="routingContext"/>
        <entry key="storageManager" value-ref="storageManager"/>
        <entry key="storageManager" value-ref="messageEventPool"/>
	</map>
</property>

...