9. State-of-the-World (SOW) Features¶
The SOW
section of the configuration file holds the configuration
for the AMPS State of the World.
Element | Description |
---|---|
Topic |
Specifies that AMPS will record distinct messages for this topic in the State of the
World. SOW topic definitions are used directly as a last-value cache, and are
required for many of the advanced messaging features in AMPS such as out-of-focus
notifications and delta messaging. SOW topic definitions can also be used as the
underlying topics for views, aggregates, and conflated topics. SOW Topic
configuration is described in SOW/Topic. |
Queue |
Defines a message queue. Rather than delivering each message to all matching subscriptions, message queues provide features to help ensure that each message is delivered to and processed by a single subscriber. See the User Guide for a full description of the functionality of message queues. Queue configuration is described in SOW/Queue. |
View |
Defines a View over one or more SOW topics, conflated topics, or other views. A view can perform aggregation, can JOIN multiple topics together. A view can be based on a SOW topic of one message type and project results of a different message type. View configuration is described in SOW/View. |
ConflatedTopic |
Defines a copy of a SOW topic or view that receives current value updates at a specified interval, conflating any changes to values that occur between the scheduled updates. ConflatedTopic configuration is described in SOW/ConflatedTopic. |
SOW section configuration elements
The elements within the SOW section are described in detail in the following sections.
SOW/Topic¶
Creating a Topic
element in the SOW configuration section
declares that AMPS will maintain state of the world for that topic. When
a topic is recorded in the State of the World (SOW), AMPS maintains the
most recent value of each distinct message in that topic. In this
respect, the SOW for a topic is similar to a table in a relational
database.
Notice that AMPS does not require topics to be predeclared. Creating this configuration item is declaring that the State of the World will be maintained for this topic: the configuration does not define a topic. Creating this configuration item is not required to publish messages to the topic.
There are several sets of options required when a topic is added to the State of the World. General options define the topic name and the overall behavior of the State of the World for this topic. Key specification options define how AMPS identifies unique messages within the topic (much like declaring a primary key for a table in a relational database). Growth specification options define how AMPS grows storage for the State of the World for this topic as messages are added.
Example (CHAPTER_NUMBER).(CONFIG_REF_ROOT_SOW_TOPIC)
contains a listing of the parameters for a Topic
section in the SOW
section of an AMPS configuration file. AMPS
accepts TopicDefinition
as a synonym for Topic
,
since this was the element name used in versions before 5.0.
This section presents brief descriptions of the options for recording the State of the World for a topic. For full information on the State of the World, see State of the World in the AMPS User Guide.
Element | Description |
---|---|
MessageType
|
Type of messages to be stored. To use AMPS generated SOW keys, the message type specified must
support content filtering so that AMPS can determine the SOW key for the message. All of the
default message types, except See the Message Types chapter in the AMPS User Guide for a discussion of the message types that AMPS loads by default. Some message types (such as Google Protocol Buffers) require additional configuration, and must be configured before using the message type in a SOW topic. |
Name
|
The name of the SOW topic - all unique messages on this topic will be stored in a topic-specific SOW database. Every SOW requires a method of determining which messages are unique. Several methods are provided within AMPS. See the AMPS User Guide for a discussion on SOW keys, and Key specification options for relevant configuration items. If no |
SOW/Topic General Options
A SOW topic must also consider the following options:
Option | Description |
---|---|
Storage and Recovery | A SOW topic must either specify the See Storage and Recovery Definition for details. |
Record Identity | A SOW topic must define how to determine whether a given message is a distinct record in the topic. Typically, record identity is based on the content of one or more fields in the message content. See Key specification options for details and options. |
Memory and File Growth | If the SOW topic will contain a large number or records, or if an individual record will exceed the default allocation size, the topic must define the allocation size. See Growth specification options for details. |
A SOW topic may also provide the following options (notice, though, that there are restrictions on how some of these options are used with other options.
Option | Description |
---|---|
Indexing | A SOW topic can declare additional hash indexes or direct AMPS to create memo indexes before a field is used by an application to improve performance. See Options for indexing for more details. |
Historical Query | A SOW topic can keep message state to allow “point in time” historical queries of current values. Notice that this option is not required for message-by-message replay; recording the topic in a transaction log provides full replay. See Options for persistence and recovery for more details. |
Message Enrichment | A SOW topic can modify the content of messages as they are received from an application. See Options for enrichment for more details. |
Regular Expression Topic Name Matching | A SOW topic can be declared as a regular expression topic, where multiple topic names use the same definition and are stored in the same physical file. This can be useful when converting a system from topic-based routing. See Options for regular expression topics for more details. |
Storage and Recovery Definition¶
These options specify the storage for the topic and recovery behavior for the topic if the topic is not durably persisted or if the recovery file is not present.
Options for storage and recovery | |
Element | Description |
FileName |
The file where the State of the World (SOW) data will be stored. This element is required for SOW topics with a This element should contain the path and the file name. The path can be either an absolute path or a path relative to the current working directory of the AMPS process. Within this element, the escape Two different topics must not share the same file. Two instances of AMPS must not share the same file. |
Durability |
Defines the data durability of a SOW topic. SOW databases listed as Notice that when the durability is Default: Valid values: When a value of Synonyms: |
RecoveryPoint |
For SOW topics that are covered by the transaction log, the point from which to recover the SOW
if the SOW file is removed, or if the SOW topic has This configuration item allows two values:
Defaults to |
Expiration |
Time for how long a record should live in the SOW database for this topic. The expiration time is stored on each message, so changing the expiration time in the configuration file will not affect the expiration of messages currently in the SOW. AMPS accepts interval values for the Expiration, using the interval format described in the AMPS Configuration Guide section on units, or one of the following special values:
Default: |
SOW/Topic Persistence and Recovery Options
Key Specification Options¶
Each SOW topic must define how AMPS will determine which messages are
unique. An application can either have AMPS determine the key by
specifying one or more Key
fields, provide a SOW key with the
publish
command each time a message is published to AMPS. AMPS also
provides the ability to provide a custom SowKey generator with a plugin
module.
See the Sow Key Generation section in the AMPS User Guide for for a full discussion. The following table lists the available configuration items for specifying how AMPS determines the SowKey for a message:
Key specification options | |||||||
---|---|---|---|---|---|---|---|
Element | Description | ||||||
Key |
Specifies an XPath-based indentifier within each message that AMPS will use to generate a SOW
key, which determines whether a message is unique. This element can be specified multiple times
to create a composite key from the combined value of the specified When one or more 60East recommends configuring a AMPS automatically creates a hash index for the set of fields specified in the There is no default for this element. |
||||||
KeyDomain |
The seed value for For example, if your application has a This option can only be specified when one or more Default: the name of the SOW topic. |
||||||
KeyGenerator |
Specifies the SOW key generator module to use for this topic. When this configuration element is present, AMPS calls the specified module to generate a SOW key for each incoming message. Default: no SOW key generator module. When there is no SOW key generator module specified, AMPS
uses the specified A KeyGenerator element contains the following elements:
|
SOW/Topic Key Specification Options
Memory and File Growth Options¶
The SOW topic configuration also specifies how the SOW file is allowed to grow. See the AMPS User Guide for details on SOW growth. The configuration options for controlling how the file is allocated and how the file grows are listed below:
Allocation and growth options | |
---|---|
Element | Description |
SlabSize |
The size of each allocation for the SOW file, as a number of bytes. When AMPS needs more space for the SOW, it requests this amount of space from the operating system. This effectively sets the maximum message size that AMPS guarantees can be stored in the SOW. This size includes headers set by AMPS on the message. 60East recommends setting this value only if you will be storing messages larger than the
default If it becomes necessary to tune the Default: |
InitialSlabCount |
The number of SOW slabs that AMPS will allocate on startup. Default: Maximum: |
DEPRECATED:
|
This parameter is deprecated beginning in AMPS 5.0. Use Default: |
DEPRECATED:
|
This parameter is deprecated beginning in AMPS 5.0. Use the Default: |
DEPRECATED:
|
This parameter is deprecated beginning in AMPS 5.0. Use the Default: |
SOW/Topic Growth Specification Options
Indexing Options¶
AMPS automatically creates a memo index for a field within a SOW topic when that field is used (for example, is used in a view or is queried by an application).
In addition, AMPS automatically creates a hash index (the primary key index) for the combination of fields used to define the SOW key. The options in this section allow you to manage index creation for a SOW topic.
Options for indexing | |
Element | Description |
HashIndex |
AMPS provides the ability to do fast lookup for SOW records based on specific fields. When one or more The AMPS uses a hash index when a query uses a exact matching for all of the fields in the index. AMPS does not use hash indexes for range queries or regular expressions. AMPS automatically creates a hash index for the set of fields specified in the set of |
Index |
AMPS supports the ability to precreate memo indexes for specific fields using the When one or more |
ExpectedKeyCountHint |
For SOW topics that will contain a large number of distinct keys, providing an expected key count allows AMPS to pre-size the data structure that holds the key. This can provide a performance improvement for publishers by avoiding cases where AMPS has to resize the data structure. There is no default for this value. When no value is provided, AMPS does not pre-size data structures for the SOW. When provided, the value of this option should be the power of 2 closest to the maximum
number of keys the topic is expected to hold. For example, a topic that is expected to hold
500,000,000 distinct records could set a value of |
SOW/Topic Indexing Options
Historical Query¶
A SOW topic can, optionally, maintain the ability to query current
values at a specific point in time. To specify this, include a
History
element in the topic configuration. The History
element must include the following options:
History configuration options | |
---|---|
Element | Description |
History/Window
|
Required when a For a historical SOW, the length of time to store history. For example, when the value is Used within the Default: By default, AMPS does not expire historical SOW data. |
History/Granularity
|
Required when a For a historical SOW, the granularity of the history to store. For many applications, it is not
necessary for AMPS to store all of the updates to the SOW. This parameter sets the resolution at
which AMPS will save the state of a message. A value of For example, when you set a granularity of Used within the |
SOW/Topic/History Options
Message Enrichment¶
AMPS can modify a message as it is published to the SOW topic from an application. See State of the World Message Enrichment in the AMPS User Guide for details.
Message enrichment options | |
Element | Description |
Preprocessing |
When present, specifies the message enrichment to be performed before AMPS determines the SOW key for the message. The |
Enrichment |
When present, specifies the message enrichment to be performed after AMPS determines the SOW key for the message. The |
SOW/Topic Preprocessing/Enrichment Specification Options
Regular Expression Topics¶
AMPS can store the last values for a set of topics that match the same naming pattern and use the same configuration in the same physical file. See State of the World Regular Expression Topics in the AMPS User Guide for details.
Regular expression topic options | |
Element | Description |
Pattern
|
When present, declares this topic to be a regular expression topic and specifies the pattern to use to determine if a topic is part of the regular expression topic. Regular expression topics have the benefits and limitations described in State of the World Regular Expression Topics in the AMPS User Guide. There is no default for this element. When this element is present, the |
SOW/Topic Regular Expression Topic Specification Options
An example of a SOW configuration looks like the following:
<SOW>
<!-- Simple SOW topic definition -->
<Topic>
<Name>orders</Name>
<Key>/orderId</Key>
<MessageType>nvfix</MessageType>
<FileName>./sow/%n.sow</FileName>
</Topic>
<!-- SOW with hash indexes -->
<Topic>
<Name>customers</Name>
<Key>/customerId</Key>
<MessageType>json</MessageType>
<FileName>./sow/%n.sow</FileName>
<!-- Index for exact match on customerName -->
<HashIndex>
<Key>/customerName</Key>
</HashIndex>
<!-- Index for exact match on company -->
<HashIndex>
<Key>/company</Key>
</HashIndex>
<!-- Index for exact match on *both*
customerName and company.
-->
<HashIndex>
<Key>/customerName</Key>
<Key>/company</Key>
</HashIndex>
</Topic>
<!-- Historical SOW -->
<Topic>
<Name>catalog</Name>
<Key>/sku</Key>
<MessageType>json</MessageType>
<FileName>./sow/%n.sow</FileName>
<History>
<Window>7d</Window>
<Granularity>15m</Granularity>
</History>
</Topic>
<!-- SOW with enrichment
Add a /fullName field constructed
from /firstName and /lastName. -->
<Topic>
<Name>sales-reps</Name>
<Key>/employeeId</Key>
<MessageType>bflat</MessageType>
<FileName>./sow/%n.sow</FileName>
<Key>/id</Key>
<Enrichment>
<Field>CONCAT(/firstName, " ", /lastName) AS /fullName</Field>
</Enrichment>
</Topic>
</SOW>
SOW Topic Configuration
SOW/Queue, SOW/LocalQueue, and SOW/GroupLocalQueue¶
This section lists configuration parameters for queues.
The Queue
tag, the LocalQueue
tag and the GroupLocalQueue
tag
are used to configure message queues.
When an AMPS queue is defined with the Queue
tag, the queue will be
a distributed queue. To make a queue that is limited to the local
instance, use the LocalQueue
configuration element. To make a queue
that is restricted to a subset of instances, in a set of replicated instances
(typically all in the same group), use the GroupLocalQueue
tag.
AMPS accepts QueueDefinition
as a synonym for Queue
.
The following configuration items apply to queues regardless of whether they are fully distributed, local, or distributed within a replication group:
Element | Description |
---|---|
Name
|
The name of the queue topic. This name is the name that consumers subscribe to. If no |
MessageType
|
The message type of the queue. |
UnderlyingTopic |
A topic name or regular expression for the topic that contains the messages to capture in the queue. These topics must be recorded in a transaction log, and all must be of the same message type as the queue. If an |
DefaultPublishTarget |
The topic to publish to when an application publishes a message to the queue. For simplicity, AMPS allows applications to publish messages to the queue, and for those messages to be routed to one of the underlying topics. The This element is required if the |
LeasePeriod |
The amount of time that a subscriber has ownership of the message before
the message is returned to the queue. For The Default: |
Semantics |
The delivery semantics to use for this queue. Regardless of the delivery semantics, AMPS queues deliver a given message to a single subscriber at a time. When a subscriber fails to process a message (that is, the connection to the subscriber closes before the message is acknowledged, or the lease expires before the message is acknowledged), the semantics specify how the failure is handled.
Default: |
MaxBacklog |
The maximum number of outstanding, unacknowledged messages in the queue at any one time. This parameter allows you to set limits on the number of pending messages from the queue overall. When the queue reaches the MaxBacklog, no incoming messages are delivered from the queue until a message is removed from the queue (either by expiring, or being acknowledged by a client). This parameter allows you to avoid overwhelming clients during periods of heavy activity. Notice that this does not set a limit of any sort on the capacity of the queue. This parameter allows you to limit the number of messages that the queue will make available to subscribers at a given time, but does not restrict the capacity of the queue to track messages. This backlog number is applied per instance of the queue. That is,
each instance of AMPS that hosts an instance of a replicated queue will
deliver messages up to the Default: |
MaxPerSubscriptionBacklog |
The maximum number of outstanding, unacknowledged messages in the queue for an individual subscription. This parameter allows you to avoid overwhelming a single subscriber during a period of heavy activity. Subscribers can declare the maximum number of messages that the subscription is prepared to lease at a given time. This maximum defaults to 1 when there is no maximum explicitly specified for a subscription. AMPS will lease the number specified in the subscription or the maximum set for the queue, whichever is lower. Notice that this does not set a limit of any sort on the capacity of the queue. This parameter allows you to limit the number of messages that the queue will make available for a single subscription at a given time, but does not restrict the capacity of the queue to track messages. Default: |
TargetQueueDepth |
The target number of messages to keep active state on. Providing this option limits the amount of state that AMPS keeps for unacknowledged messages. In most circumstances, the limit will be the number of messages specified in this parameter. If this instance receives a transfer request for a message that is in the transaction log, but outside the currently active set of messages, AMPS will process the queue until it reaches the message to be transferred. Messages that are present in the transaction log, but
for which AMPS does not currently have active state, are not deliverable
from the queue topic, cannot be queried, cannot be deleted using a
This option is not set by default. When this option is not set, all messages in the queue are active. This option is typically unnecessary if the This option cannot be set if When this parameter is set, it should be set to a number that accounts for several seconds of traffic to the queue, considering replication and acknowledgment speeds. For example, if a queue is typically processed at a rate of 2500 messages per second within minimal replication delays, a reasonable minimum target value might be 12500 or 15000. Notice that, if subscribers use content filters to selectively process the queue, if no currently active messages match the subscription, no messages will be delivered (even if there are matching messages in the queue that are not currently active). Default: unset (no limit)
Minimum: |
Expiration |
The length of time a message can remain in the queue before AMPS considers the message undeliverable. Messages may expire while a subscriber has a lease on the message. AMPS does not send an additional notification in this case. A publisher can override this setting by providing an expiration value on an incoming message. If an individual message in the transaction log has an expiration value, AMPS will use that expiration value for the message rather than the default for the queue. Default: |
Filter |
An AMPS By default, there is no filter and all messages from the
|
RecoveryPoint |
This option allows you to specify the point at which AMPS begins reviewing the transaction log to recover the state of the queue when AMPS restarts and there is no existing information about the state of the queue. By default, AMPS reviews the full log to determine the contents and state of the queue. If AMPS has a record of the last point in the transaction log at which
all previous messages are acknowledged (stored in the The
Default: |
FairnessModel |
AMPS provides different methods to distribute messages across active subscriptions:
Each instance of AMPS independently manages the fairness model for subscriptions on that instance. Fairness model information is not replicated across instances. Default: |
Leasing |
Ownership model for leased messages. AMPS supports the following models:
Default: |
MaxDeliveries |
Specifies an upper bound to the number of times AMPS may deliver a queue
message before automatically expiring it. For example, if AMPS delivers
a message twice and This counter is reset if the server restarts and the counter is not replicated to other instances. Default: no maximum ( |
MaxCancels |
Specifies a limit to the number of times a subscriber may cancel a lease
on a message before it is expired. For example, if a message is canceled
for the second time and This counter is reset if the server restarts and the counter is not replicated to other instances. Default: no maximum ( |
Priority |
Specifies the order in which messages will be distributed from the queue. When present, this element constructs a value that specifies the priority for messages in the queue. Higher priority messages are delivered first, regardless of the order in which messages have been published to the queue. The contents of the element can be either the name of a field in the
message or an AMPS expression. Either way, the result is treated as an
For example, to order message delivery based on the <Priority>/priority</Priority>
To order message delivery based on the product of the <Priority>/price * /qty</Priority>
Default: there is no default for this value. When not provided, the delivery order is the order in which messages were processed by this instance of AMPS. This option cannot be specified on a queue if |
BarrierExpression |
Specifies the filter used to identify a barrier message (synchronization point) for this queue. When a message matches this expression, it will be delivered to all current subscribers on the queue when every previous message in the queue has been acknowledged. This provides a simple, reliable way to synchronize workers. <BarrierExpression>/isSyncPoint IS NOT NULL</BarrierExpression>
The Default: there is no default for this value. When not provided, no messages are considered to be barrier messages This option cannot be specified on a queue if |
DeferredAckExpiration |
Specifies the amount of time for AMPS to retain information about an
acknowledgment ( This element is configured as an interval, for example, The default value is generally recommended. However, in cases where an instance may receive large volumes of acknowledgments for messages that are not currently in the queue, and are not expected to arrive, setting this to a lower value may somewhat reduce the memory required for managing these acknowledgments. Default: |
FileBackedMetadata |
Specifies whether AMPS should persist metadata about the queue in the journal directory. This could reduce the active memory footprint of an AMPS instance in cases where a queue has a large number of messages, but it is not being actively consumed. In cases where the queue has a large number of unacknowledged messages when AMPS is restarted, this may also improve recovery time. This option can be unset or set to a value of Default: unset, which indicates that queue metadata will not be persisted |
Queue configuration elements
When a queue is defined as a GroupLocalQueue
, the following configuration item must be provided:
Element | Description |
---|---|
InitialOwner
|
For a group local queue, provides the instance This configuration element is required for a All instances in a replicated system that define this queue must
define the same Notice that AMPS does not validate that the This element is required. There is no default for this element. |
When a queue is defined as a GroupLocalQueue
, the following optional configuration element may
be provided.
Element | Description |
---|---|
GroupLocalQueueDomain |
For a group local queue, provides a way to allow a queue that is hosted in instances that are in different replication groups to be identified as the same queue and function as a single distributed queue. By default, a When this element is defined, the This element was introduced in version 5.3.4. Previous versions do
not consider the |
Additional configuration elements for GroupLocalQueue
The following configuration snippet shows one way to configure a queue.
<!-- Notice that the topics to use for the queue (ORDERS_.*) must be
recorded in a transaction log. -->
<SOW>
<Queue>
<Name>MQ</Name>
<MessageType>json</MessageType>
<UnderlyingTopic>ORDERS_.*</UnderlyingTopic>
<DefaultPublishTarget>ORDERS_DIRECT</DefaultPublishTarget>
<LeasePeriod>60s</LeasePeriod>
<Expiration>1d</Expiration>
<MaxBacklog>3</MaxBacklog>
</Queue>
</SOW>
The following configuration snippet shows the configuration for a
GroupLocalQueue
. Any instance of the queue in the group
named CONSUME_INSTANCES
or that uses the GroupLocalQueueDomain
tag of CONSUME_INSTANCES
will be treated as an instance
of the same queue.
<SOW>
<GroupLocalQueue>
<Name>GroupQueue</Name>
<MessageType>json</MessageType>
<UnderlyingTopic>ORDERS_.*</UnderlyingTopic>
<DefaultPublishTarget>ORDERS_DIRECT</DefaultPublishTarget>
<GroupLocalQueueDomain>CONSUME_INSTANCES</GroupLocalQueueDomain>
</GroupLocalQueue>
</SOW>
SOW/View¶
Table 9.6 contains a listing of the parameters for a View
section in the SOW
section of an AMPS configuration file. For
backward compatibility, AMPS accepts ViewDefinition
as a synonym for View
.
Element | Definition |
---|---|
MessageType
|
The message type of the view. This does not need to be the same type as any of the topics in the aggregation, but does need to be a message type that supports views. The message type must be one of the message types
configured for the instance. AMPS includes Notice that the Other message types provided with AMPS may have limitations in their support for views. see the Message Types chapter in the AMPS User Guide for a discussion of the limitations. |
Name
|
Defines the topic name for this view. If no |
UnderlyingTopic
|
Defines the SOW topic or topics on which this view is
based. This element can contain a single topic name,
or any number of Join elements. |
Projection/Field
|
Defines what the view will contain. This element can be specified multiple times to compose a complex view. Complex expressions that use aggregation functions and conditional branching can also be used. |
Grouping/Field
|
Defines how the records in the underlying topic will be grouped. This is analogous to a SQL GROUP BY clause. |
KeyDomain |
The seed value for SowKeys used within this topic.
The default is the topic name, but it can be changed
to a string value to unify SowKey values between
different topics. |
Join |
Within an An |
Conflation |
Defines whether AMPS will attempt to conflate updates to the view. This item accepts two values:
Default: |
Filter |
Defines a filter for the view. When provided, only messages from the underlying topic that match this filter will be included in the view. This option is only valid when the view uses a
single Default: No filter, which includes all messages from
the |
HashIndex |
AMPS provides the ability to do fast query lookup for records in a view based on specific fields. When one or more The AMPS uses a hash index when a query uses an exact string match for all of the fields in the index. AMPS does not use hash indexes for range queries or regular expressions, or for numeric comparisions. AMPS automatically creates a hash index for the fields
specified in the |
JoinNullEquivalency |
Specifies whether the Default: |
FileName |
File location to store view data. Unused in this version of AMPS. |
Table 9.6: SOW/View
<SOW>
<!-- Single topic aggregation -->
<Topic>
<Topic>/ett/order</Topic>
<MessageType>fix</MessageType>
<Key>/orderId</Key>
</Topic>
<View>
<MessageType>nvfix</MessageType>
<Topic>TOTAL_VALUE</Topic>
<UnderlyingTopic>/ett/order</UnderlyingTopic>
<Projection>
<Field>/109</Field>
<Field>SUM(/14 * /6) AS /71406</Field>
</Projection>
<Grouping>
<Field>/109</Field>
</Grouping>
</View>
<!-- Single topic aggregation with filter -->
<Topic>
<Name>orders</Name>
<MessageType>json</MessageType>
<Key>/orderId</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>CompleteByRegion</Name>
<UnderlyingTopic>orders</UnderlyingTopic>
<MessageType>json</MessageType>
<Projection>
<Field>COUNT(/orderId) AS /completedOrders</Field>
<Field>/region AS /region</Field>
</Projection>
<Grouping>
<Field>/region</Field>
</Grouping>
<Filter>/status = 'complete'</Filter>
</View>
<!-- Single topic aggregation with a hash index
for faster query. -->
<Topic>
<Name>source-for-hash-sample</Name>
<MessageType>json</MessageType>
<Key>/id</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>hash-sample-view</Name>
<MessageType>json</MessageType>
<UnderlyingTopic>source-for-hash-sample</UnderlyingTopic>
<Projection>
<Field>SUM(/qty) as /quantity</Field>
<Field>/customerName</Field>
<Field>/orderType</Field>
</Projection>
<Grouping>
<Field>/customerName</Field>
<Field>/orderType</Field>
</Grouping>
<!-- provide fast query for exact matches on
*either* name or orderType -->
<HashIndex>
<Key>/name</Key>
</HashIndex>
<HashIndex>
<Key>/orderType</Key>
</HashIndex>
</View>
<!-- Project from one message type to another -->
<Topic>
<Name>example</Name>
<MessageType>json</MessageType>
<Key>/id</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<!-- notice that nvfix topic named 'example' is not the same topic as the json
topic named 'example' -->
<Name>example</Name>
<MessageType>nvfix</MessageType>
<UnderlyingTopic>[json].[example]</UnderlyingTopic>
<Projection>
<Field>[json].[example]./id AS /id</Field>
</Projection>
<Grouping>
<Field>[json].[example]./id</Field>
</Grouping>
</View>
<!-- JOIN topics -->
<Topic>
<Name>ORDERS</Name>
<MessageType>nvfix</MessageType>
<Key>/OrderID</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<Topic>
<Name>COMPANIES</Name>
<MessageType>nvfix</MessageType>
<Key>/CompanyId</Key>
<FileName>./sow/%n.sow</FileName>
</Topic>
<View>
<Name>TOTAL_COMPANY_VOLUME</Name>
<UnderlyingTopic>
<Join>[ORDERS]./Tick = [COMPANIES]./Tick</Join>
</UnderlyingTopic>
<MessageType>nvfix</MessageType>
<Projection>
<Field>[COMPANIES]./CompanyId</Field>
<Field>[COMPANIES]./Tick</Field>
<Field>[COMPANIES]./Name</Field>
<Field>SUM([ORDERS]./Shares) AS /TotalVolume</Field>
</Projection>
<Grouping>
<Field>[ORDERS]./Tick</Field>
</Grouping>
</View>
</SOW>
Example 9.2: View Example
SOW/ConflatedTopic¶
AMPS provides the ability to create ongoing snapshots of a SOW topic, called conflated topics (also called topic replicas in previous releases of AMPS). Conflated topics are updated on an interval, and store a snapshot of the current state of the world at each interval. This helps to manage bandwidth to clients that do not act on each update, such as a client UI that refreshes every second rather than with every update.
For compatibility with previous AMPS versions, AMPS allows you to use
ReplicaDefinition
as a synonym for ConflatedTopic
.
Element | Description |
---|---|
Name
|
String used to define the name of the conflated topic.
While AMPS doesn’t enforce naming conventions, it can
be convenient to name the conflated topic based on the
underlying topic name. For example, if the underlying
topic is If no |
UnderlyingTopic
|
String used to define the SOW topic which provides updates to the conflated topic. This must exactly match the name of a SOW topic. When the underlying topic is a regular expression topic, this must match the
|
MessageType
|
The message format of the underlying topic. This
MessageType must be the MessageType of the
provided UnderlyingTopic . |
Interval |
The frequency at which AMPS updates the data in the conflated topic. Default: Minimum: |
Filter |
Content filter that is applied to the underlying topic. Only messages that match the content filter are stored in the conflated topic. |
HashIndex |
AMPS provides the ability to do fast lookup for SOW records based on specific fields. When one or more The AMPS uses a hash index when a query uses exact matching for all of the fields in the index. AMPS does not use hash indexes for range queries or regular expressions. AMPS automatically creates a hash index for the set of fields specified in the set of |
SOW/ConflatedTopic Parameters
If the underlying topic of a ConflatedTopic
is a regular expression topic, an additional configuration
parameter is required to specify the topic name that AMPS will use for each conflated topic.
Element | Description |
---|---|
TopicFormat
|
String used to format the name of the conflated topics when the underlying topic is a regular expression topic. When the underlying topic is a regular expression topic, AMPS will create a conflated topic for each topic within the regular expression topic. This element specifies how AMPS will construct the name of the conflated topics produced. The For example, if the There is no default for this element. This element cannot contain
characters that are significant for regular expressions (such as
|
SOW/ConflatedTopic Parameters when the UnderlyingTopic is a regular expression topic
<ConflatedTopic>
<Topic>FastPublishTopic-C</Topic>
<MessageType>nvfix</MessageType>
<UnderlyingTopic>FastPublishTopic</UnderlyingTopic>
<Interval>5s</Interval>
<Filter>/region = 'A'</Filter>
</ConflatedTopic>
<ConflatedTopic>
<Topic>LongIntervalTopic-C</Topic>
<MessageType>json</MessageType>
<UnderlyingTopic>FastPublishTopic</UnderlyingTopic>
<Interval>120s</Interval>
<HashIndex>
<Key>/order/status</Key>
</HashIndex>
</ConflatedTopic>
<ConflatedTopic>
<Topic>ConflateUnderlyingRegex</Topic>
<MessageType>bflat</MessageType>
<UnderlyingTopic>TheRegexTopic</UnderlyingTopic>
<Interval>20s</Interval>
</ConflatedTopic>