Versions Compared

Key

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

Table of Contents

Overview

FIXEdge/J provides the an ability to store information in the memory for purposes of message enrichment during the routing process. This functionality is based on a key-value storage

While processing a message from one endpoint to another, FIXEdge/J may store any information in the storage and then retrieve it while routing in the opposite direction.

Advantages: storing data in-memory data storing confers performance advantages.

Disadvantages: FIXEdge/J will lose all stored information on restart. 

Configuration

There are several methods in the Groovy rules that can be used for this functionality:

Method nameMethods signatureDescriptionExample
saveContextObject saveContext(Object key, Object value)

Associates the specified value with the specified key in this storage. If the storage previously contained a mapping for the key, the old former value is replaced by the specified value.


Params:

  • key – the key with which the specified value is to be associated
  • value – the value to be associated with the specified key

Returns:

  • the previous value associated with the key, or NULL if there was no mapping for the key.

def senderCompID = msg.getTagValueAsString(49)
def clOrdId = msg.getTagValueAsString(11)
def uniqueId = generateUniqueId()
saveContext(uniqueId, [49: senderCompID, 11: clOrdId])

or

def senderCompID = msg.getTagValueAsString(49)
def clOrdId = msg.getTagValueAsString(11)
def uniqueId = generateUniqueId()
saveContext(uniqueId + 49, senderCompID)
saveContext(uniqueId + 11, clOrdId)

removeContextObject removeContext(Object key)

Removes the mapping for the key from the given storage if it is present.

The storage will not contain a mapping for the specified key once the call returns.

Params:

  • key – the key whose which mapping is to be removed from the storage

Returns:

  • the previous value associated with the key, or NULL if there was no mapping for the key.

def uniqueId = msg.getTagValueAsString(11)
removeContext(uniqueId)

getContextObject getContext(Object key)

Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for the key.

Params:

  • key – the key whose with which the associated value is to be returned

Returns:

  • the value to which the specified key is mapped, or NULL if this map contains no mapping for the key

def uniqueId = msg.getTagValueAsString(11)
def savedContext = getContext(uniqueId)
msg.set(11, savedContext.get(11))

or


def uniqueId = msg.getTagValueAsString(11)
def savedId = getContext(uniqueId + 11)
msg.set(11, savedId)

cleanContextvoid cleanContext(Predicate<Map.Entry<Object, Object>> consumer)Removes entries from the context according to the provided predicate.

cleanContext({entry -> entry.getKey() == "orderId"})

...

ClOrdID replacement

Business case: broker Broker should replace the identificators provided by the Clients to the IDs corresponding to Exchange's requirements and format.

...