Table of Contents |
---|
Transport adapter
...
Code Block | ||
---|---|---|
| ||
//remove all items and clean file queue.clear(); |
Routing Rules
FIX Edge Java provides an RoutingRule
unit as an abstraction for internal message routing element. FEJ supports pure Java and Groovy implementations for routing rules.
RoutingRule requires few components for its instantiation:
Code Block | ||
---|---|---|
| ||
public RoutingRule(java.lang.String description,
SourceCondition sourceFilter,
RuleCondition contectFilter,
RuleAction action) |
description - String with free test description of rule
source filter - check if this rule should be applied to messages from certain source. This filter was added as a separate with propose of optimization process. Such filter can by applied on static basis without addition affect in runtime. Source filter is
SourceCondition
implementation and can be null if you’d like to ignore it.context filter - dynamic filter, which can check in the same time appliance of this rule depends on message content and source attributes. Context filter is
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 required destination.
Sample of routing rule:
Code Block | ||
---|---|---|
| ||
import com.epam.fej.routing.RoutingContext
import com.epam.fej.routing.rules.RoutingRule
import com.epam.fej.routing.rules.RuleAction
import com.epam.fej.routing.rules.RuleCondition
import static com.epam.fej.routing.CustomRoutingRules.getDefaultRules
import static com.epam.fej.routing.CustomRoutingRules.getRejectionRule
RoutingContext rc = routingContext as RoutingContext;
[
new RoutingRule(
// rule description
"some Rule",
//source filter - ignore for this rule
null,
// context filter - apply this rule for New Order - Single (D) messages
{ ctx -> ctx.getMessage().getTagValueAsString(35) == "D" } as RuleCondition,
// 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),
// append system rejection rules for not processed messages
getRejectionRule(rc)
] |