How Does the State of the World Work?
This section provides details on the AMPS State of the World functionality.
Last updated
This section provides details on the AMPS State of the World functionality.
Last updated
Copyright 2013-2024 60East Technologies, Inc.
AMPS SOW topics persist the most recent update for each message, in the same way that a relational database stores the current state of each record. For performance, AMPS SOW topics store the full content of the message verbatim rather than storing a deserialized or "shredded" version of the message.
Each distinct record in a SOW topic is identified by a SOW key. AMPS treats the SOW key for a SOW topic the same way a relational database uses the primary key for a table: each distinct SOW key value is a unique message.
There are several ways to create a SOW key for a message. Each topic defines one of the following strategies:
Most applications specify that AMPS will calculate a SOW key based on the content of the message. The configuration of the topic specifies the field, or fields, to be used for the key.
A topic can also be configured to require that a publisher provide a SOW key for each message when publishing the message to AMPS. This is less commonly used than determining the key based on the message content, however, since this strategy does not require any explicit configuration, AMPS will default to this strategy for identifying messages if no other strategy is specified.
AMPS also supports the ability for custom SOW key generation logic to be defined in an AMPS module, which will be invoked to generate the SOW key for each message.
Although the SOW key is derived from the content of the message in many cases, the SOW key itself is metadata, distinct from the content of the message. Each record in a SOW topic has a distinct SOW key, which is stored with the record.
For example, the diagram below shows how AMPS computes the SOW key for a topic named ORDERS with a key definition of /orderId
. For each publish to the topic, AMPS uses the value of the key fields (in this case, simply /orderId
) to compute a SowKey
, then uses that SowKey
to insert or update the appropriate record.