Message Functions
AMPS includes functions that can be used to refer to the current message being processed.
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.
MESSAGE_SIZE
MESSAGE_SIZE
MESSAGE_SIZE()
Returns the size of the payload of the current message, in bytes.
Parameters
None.
Returns
The size of the message payload in bytes.
Available For
All messages.
CORRELATION_ID
CORRELATION_ID
CORRELATION_ID()
Returns the correlation ID of the current message as a string.
Parameters
None.
Returns
The correlation ID of the current message, or NULL
if there is no correlation ID.
Available For
All messages.
LAST_UPDATED
LAST_UPDATED
LAST_UPDATED()
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.
Parameters
None.
Returns
A timestamp for the last time the message was updated.
Available For
Queries of a SOW topic.
BOOKMARK
BOOKMARK
BOOKMARK()
Returns the bookmark for the current message, if one is available.
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.
Parameters
None.
Returns
The bookmark for the current message.
Available For
- Subscriptions to a transaction-logged topic
- Bookmark subscriptions to a transaction-logged topic
- SOW delete by filter for a transaction-logged topic
LAST_LEASED
LAST_LEASED
LAST_LEASED()
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.
Parameters
None.
Returns
A timestamp for the last time this message was leased.
Available For
- Queries of a message queue
- Subscription to a message queue
- SOW delete by filter for a message queue
LEASE_COUNT
LEASE_COUNT
LEASE_COUNT()
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.
Parameters
None.
Returns
The number of times the message has been leased.
Available For
- Queries of a message queue
- Subscription to a message queue
- SOW delete by filter for a message queue