On Message Published to AMPS
AMPS provides modules to run actions when a message is published to AMPS. The basic flow of AMPS messaging is to first receive a published message, find the subscriber(s) to which this message will be sent, then deliver that message to the subscriber(s).
The amps-action-on-publish-message
runs actions as soon as a message is published to AMPS.
This action is treated by the AMPS engine as a subscription from an internal AMPS client.
When working with queues, use this action with the underlying topic of the queue rather than the queue topic itself. Because this action creates a subscription, using this action with the queue topic will cause the action to lease messages from the queue even though the action does not acknowledge messages. This means that, when used with the queue topic itself, the action will interfere with other subscribers and depending on the queue configuration, may only receive one message during the lifetime of the instance.
This module requires the Topic
and the MessageType
of the message that was published. In addition to that, this module also accepts the optional parameters listed below:
Parameter | Description |
---|---|
| The name of the topic to monitor for publishes. This parameter supports regular expressions. There is no default for this parameter. |
| The message type of the topic to monitor for publishes. There is no default for this parameter. |
| The source to monitor for publishes. The source of the message defaults to This parameter also accepts |
| Sets the filter to apply. Only messages that match this filter will cause the action to run. |
| Sets the options to apply when listening for messages. This action supports any option that would be supported by the subscribe command when not using a bookmark. |
This module adds the following variables to the AMPS context:
Variable | Description |
---|---|
| The topic of the message. |
| The data the message contains. |
| The length of the data that the message contains. |
| The bookmark associated with this message. |
| The time at which the message was processed by AMPS. |
| The name of the client from which the message was published. |
Last updated