Message Functions

AMPS includes functions that can be used to refer to the current message being processed.

Function
Parameters
Description
Available For

MESSAGE_SIZE

(none)

Returns the size of the payload of the current message, in bytes.

All messages

CORRELATION_ID

(none)

Returns the correlation ID of the current message as a string.

Returns NULL if there is no correlation ID for the current message.

All messages

LAST_UPDATED

(none)

Returns a timestamp for the last time that a message in the SOW was updated, as a double.

For a subscription (including the subscription part of a sow_and_subscribe command), the LAST_UPDATED value will be the current timestamp. This function is most useful for queries of a topic in the SOW.

Notice that this field is set based on when the local instance has updated the message.

For replicated topics, this means that a given message will have different values on different instances.

Queries of a SOW topic

BOOKMARK

(none)

Returns the bookmark for the current message, if one is available. Notice that messages retrieved from a SOW topic using a query return NULL for BOOKMARK, since the SOW does not store the bookmark of a message.

Bookmarks are assigned using a combination of an identifier derived from the client name and a sequence number.

When working with bookmarks, 60East recommends treating bookmarks as opaque identifiers. In particular, bookmarks are not guaranteed to sort in any particular order between different publishers.

AMPS only assigns bookmarks when a message is stored in the transaction log. Messages that are not in the transaction log do not have bookmarks assigned.

Subscriptions to a transaction-logged topic

Bookmark subscriptions

Subscriptions to a message queue

Replication filters

TOPIC_NAME

(none)

Returns the topic name for the message currently being processed. When used in a filter for a message being delivered from a queue that has multiple underlying topics, returns the name of the underlying topic.

All messages

SOW_KEY

(none)

Returns the SOW key for the message currently being processed, if one exists.

This function is designed for use in enrichment. In a query, subscription, or delete command, using the SowKeys header with the key or keys of interest is more efficient. Although the function will return a value when used in a filter, using SowKeys is recommended.

Queries or enrichment of a SOW topic

Subscriptions to a SOW topic

SOW_KEY_HASH

(none)

Returns a hash value of the SOW key for the message currently being processed. If AMPS generated the SOW key, this value will be the same value as the SOW key.

For topics where the publisher provides the SOW key, this will be a hash of the value provided by the publisher.

This function is designed for use in enrichment.

Queries or enrichment of a SOW topic

Subscriptions to a SOW topic

LAST_READ

(none)

Returns a timestamp for the last time that this message was read from the SOW, as a double.

This function only returns a value for messages in a topic in the SOW.

The LAST_READ time for a message resets when AMPS restarts.

Notice that this field is set based on when the local instance processes a read of the message.

For replicated topics, this means that a given message will have different values on different instances.

This function is non-deterministic, and cannot be used in contexts that require a deterministic function.

Queries of a SOW topic

LAST_LEASED

(none)

For a message in a queue, returns a timestamp for the last time this message was leased from this instance, as a double.

Returns NULL for a message that is not in a queue.

Notice that this timestamp is set based on when the local instance leased the message.

This counter is reset when the instance restarts.

Queries of a message queue

Subscription to a message queue

SOW delete by filter for a message queue

LEASE_COUNT

(none)

For a message in a queue, returns the number of times the message has been leased from this instance as a double.

Returns NULL for a message that is not in a queue.

Notice that this counter is set based on leases from the local instance.

This counter is reset when the instance restarts, and does not track leases from other instances.

Queries of a message queue

Subscription to a message queue

SOW delete by filter for a message queue

When used in view construction or aggregate definition, these functions refer to the incoming message that is prompting the update to the view or aggregate, not to the constructed message that is the result of the update. For example, a Field like this in a view projection:

<Projection>
  ...
  <Field>TOPIC_NAME() AS /theTopic</Field>
  ...
</Projection>

will return the topic name of the topic that prompted the update to the view, not the name of the view itself.

Last updated

Copyright 2013-2024 60East Technologies, Inc.