Chaining Key Generator
The AMPS distribution includes a module that can generate a SOW key for a set of chained messages.
Message chains are most frequently used in FIX order processing systems to track a set of updates to an original order from a set of systems that use unique local identifiers for the order. As messages arrive, AMPS must update the record for the original order, regardless of whether the identifier on the current message is the original order, or is an order chained to the original order.
A message chain allows an application to treat any update to an identifier in the chain as an update to the original message in the chain. The libamps_id_chaining_key_generator
module supports this by generating the same SOW key for any message in the chain. To use this module, messages must have a field that identifies the current message and a field that identifies the previous message in the message chain, if one exists.
Chained Message Sample Case
Consider a message processing scheme that uses two fields to identify related messages. Each message contains a DocumentNumber
field that indicates the current document. If the message updates or extends an existing document, the message contains a ParentDocument
that, when present, refers to the DocumentNumber
of the document that the message updates or extends.
With the default SOW key generator, each of the following messages would be a distinct message in the SOW topic:
With the default SOW key generator, at the end of the publishing process, the SOW contains four distinct records:
However, with the chaining key generator, AMPS is able to combine these messages into a single chain and produces the following single record:
The sequence of events for producing this message is as follows:
When the first message arrives with a
/DocumentNumber
of1
, the module begins a new chain (since there is no/ParentDocument
present).When the second message arrives, the module knows that it is an update to the same message since the message contains a
/ParentDocument
value. In this case, because the value is1
, the update is to the first message received. The module also adds a/DocumentNumber
of2
to the chain, so that subsequent messages that refer to a/ParentDocument
of2
are a part of the chain and update the same message.The same process occurs for the third message: the module looks up the message that should be updated when the
/ParentDocument
is2
, and traces the chain back to the original underlying message. The module adds a/DocumentNumber
of3
to the chain, so that updates with a/ParentDocument
of3
will update the same message.When the last message arrives, the module knows that a
/ParentDocument
of1
is still an update to the same message, since this is the original value. The module adds the value4
to the chain.
In each case, rather than simply using the fields in the message directly, the module creates a chain of linked identifiers: each identifier in the chain produces the same SOW key as the first identifier in the chain, so each update in the chain updates the same message.
It is an error for a publisher to publish a message that resolves to two different message chains. If the module receives such a message, the module will not generate a SOW key, and the message is not processed by AMPS.
Configuring the Chaining Key Generator
To load the module in AMPS, add the following configuration item to the Modules
block of the AMPS configuration file:
You then use the module as the KeyGenerator
for each topic in the SOW that will use chaining key generation.
The module accepts the following options:
Example
The example configuration file below shows one way to use the chaining key generator module.
Notice that once the module is loaded, it can be used for any message type, and can accept different configuration values for each topic in the SOW that uses the generator.
Last updated