ltm rule command MQTT retainΒΆ

iRule(1)					  BIG-IP TMSH Manual					     iRule(1)

MQTT::retain
       Get or set retain flag of MQTT PUBLISH message.

SYNOPSIS
       MQTT::retain ('0' | '1')?

DESCRIPTION
       This command can be used to get or set retain flag of MQTT message.  This command is valid only for following
       MQTT message types:

	   PUBLISH

       Syntax

       MQTT::retain [ 0 | 1 ]

       MQTT::retain
	   * Get the retain flag of MQTT PUBLISH message.

       MQTT::retain 0
	   * Reset the retain flag of MQTT PUBLISH message.

       MQTT::retain 1
	   * Set the retain flag of MQTT PUBLISH message.

RETURN VALUE
       When called without an argument, this command returns the retain flag of MQTT PUBLISH message.

VALID DURING
       MQTT_CLIENT_INGRESS MQTT_SERVER_INGRESS MQTT_CLIENT_DATA MQTT_SERVER_DATA MQTT_CLIENT_EGRESS
       MQTT_SERVER_EGRESS

EXAMPLES
	# Convert PUBLISH for topics in a retain_datagroup to retain messages
	when MQTT_CLIENT_INGRESS {
	   set type [MQTT::type]
	   switch $type {
	      "PUBLISH" {
		  if {[MQTT::retain] eq 0} {
		      if { [class exists retain_datagroup] } {
			  if {[class match [MQTT::topic] starts_with retain_datagroup]} {
			     MQTT::retain 1
			  }
		      }
		  }
	      }
	   }
	}

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-13.0.0 --First introduced the command.

BIG-IP						      2020-06-23					     iRule(1)