Query SOW Topic

AMPS provides a module for querying a SOW topic. The amps-action-do-query-sow queries the SOW topic, and stores the first message returned by the SOW query into a user-defined variable.

This module requires the Topic, MessageType and Filter parameters to identify the query to run. This module requires the CaptureData parameter in order to be able to store the result of the query.

ParameterDescription

Topic (required)

The name of the topic to query.

This topic must be a SOW topic, a view, a queue, or a conflated topic.

There is no default for this parameter.

This parameter supports regular expressions.

MessageType (required)

The message type of the topic to query.

There is no default for this parameter

Filter (required)

Set the filter to apply.

If a Filter is present, only messages matching that filter will be returned by the query.

CaptureData (required)

Sets the name of the variable within which AMPS will store the first message returned.

DefaultData

If no records are found, AMPS stores the DefaultData in the variable specified by CaptureData.

OrderBy

An OrderBy expression to use to order the results returned by the query.

For example, to order in descending order of the /date field in the messages, you would provide an OrderBy option of /date DESC.

Options

The options for the query.

This action accepts any valid option for a sow command except the top_n option (since this action is already limited to a top_n value of 1).

Once you query a message from the SOW topic, you can use the captured data in other actions. The example below uses amps-action-do-query-sow to query the SOW on a schedule in order to echo messages to the log for diagnostic purposes:

<Actions>
    <Action>
        <On>
            <Module>amps-action-on-schedule</Module>
            <Options>
                <Every>Saturday at 23:59</Every>
                <Name>Diagnostic_Schedule</Name>
            </Options>
        </On>
        <Do>
            <Module>amps-action-do-query-sow</Module>
            <Options>
                <MessageType>xml</MessageType>
                <Topic>SOW_TOPIC</Topic>
                <Filter>/Trans/Order/@Oname = 'PURCHASE'</Filter>
                <CaptureData>AMPS_DATA</CaptureData>
            </Options>
        </Do>
        <Do>
            <Module>amps-action-do-extract-values</Module>
            <Options>
                <MessageType>xml</MessageType>
                <Data>{{AMPS_DATA}}</Data>
                <Value>SAVED_VARIABLE=/Value</Value>
            </Options>
        </Do>
        <Do>
            <Module>amps-action-do-echo-message</Module>
            <Options>
                <Message>{{SAVED_VARIABLE}} was in the message</Message>
            </Options>
        </Do>
    </Action>
</Actions>

Last updated

Copyright 2013-2024 60East Technologies, Inc.