ltm rule command MQTT collect
iRule(1) BIG-IP TMSH Manual iRule(1)
MQTT::collect
Collect the specified amount of MQTT message payload data
SYNOPSIS
MQTT::collect (COLLECT)?
DESCRIPTION
Collects the specified amount of MQTT message payload data before triggering a MQTT_CLIENT_DATA or
MQTT_SERVER_DATA event.
When collecting data in a clientside event, the MQTT_CLIENT_DATA event will be triggered. When collecting
data in a serverside event, the MQTT_SERVER_DATA event will be triggered.
This command is valid only for following MQTT message types:
PUBLISH
This command allows you to perform various operations on MQTT PUBLISH message like modify its contents. NOTE:
Please make sure that MQTT PUBLISH message expects to receive a payload by using [MQTT::payload length]. This
is to make sure that the payload length is not zero before calling this command.
Syntax
MQTT::collect []
MQTT::collect
Collect the entire payload of the MQTT message. To stop collecting
use MQTT::release command.
MQTT::collect
Collect bytes of payload of the MQTT message.
If paylaod is smaller than collect entire payload.
The collected data can be accessed via the MQTT::payload command.
To stop collecting use MQTT::release command.
RETURN VALUE
VALID DURING
MQTT_CLIENT_INGRESS MQTT_CLIENT_DATA MQTT_SERVER_INGRESS MQTT_SERVER_DATA
EXAMPLES
#Example: Prohibit PUBLISH payloads with blocked keywords defined in
#blacklisted_keywords_datagroup in first 200 bytes
#
when MQTT_CLIENT_INGRESS {
set type [MQTT::type]
switch $type {
"PUBLISH" {
if { [class exists blacklisted_keywords_datagroup] } {
MQTT::collect 200
}
}
}
}
when MQTT_CLIENT_DATA {
set type [MQTT::type]
switch $type {
"PUBLISH" {
set payload [MQTT::payload]
MQTT::release
set found [class match $payload contains blacklisted_keywords_datagroup]
if { $found != "" } {
MQTT::disconnect
}
}
}
}
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-13.0.0 --First introduced the command.
BIG-IP 2020-06-23 iRule(1)