Pubsub recieves retained MQTT messae continious

I have written a schetch that subscribes to a MQTT topic. This works perfectly if I publish a message without the retained flag. However, if the message is published with the retain flag on, then my sketch recieves the message over and over again (every few seconds). I would like to be able to publish retained messages, is there some way I can change the code such that it will only recieve the retained message once?

#include <WiFi.h>
#include <PubSubClient.h>
//#include <OneWire.h>
//#include <DallasTemperature.h>

/* change it with your ssid-password */
const char* ssid = "ID";
const char* password = "PW";
/* this is the IP of PC/raspberry where you installed MQTT Server 
on Wins use "ipconfig" 
on Linux use "ifconfig" to get its IP address */
const char* mqtt_server = "ID";
const char* willTopic = "PW";
const char* willMessage = "Offline";
boolean willRetain = true;
/* topics */
#define TEMP_TOPIC_WATER    "PoolTemp/Water"
#define TEMP_TOPIC_AIR    "PoolTemp/Air"
#define TEMP_TOPIC_LWT    "PoolTemp/LWT"
#define TEMP_TOPIC_SUBSCRIBE "Phyn/Command"


/* create an instance of PubSubClient client */
WiFiClient espClient;
PubSubClient client(espClient);



char msg[20];

void mqttconnect() {
  /* Loop until reconnected */
  while (!client.connected()) {
    Serial.print("MQTT connecting ...");
    /* client ID */
    String clientId = "ESP32Client";
    /* connect now */
    if (client.connect(clientId.c_str(), "ID", "PW",willTopic, 1, 1, willMessage)) {
      Serial.println("connected");
      /* subscribe topic with default QoS 0*/

    } else {
      Serial.print("failed, status code =");
      Serial.print(client.state());
      Serial.println("try again in 5 seconds");
      /* Wait 5 seconds before retrying */
      delay(5000);
    }
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
  String value;
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) {
    Serial.print((char)payload[i]);
    value= value + (char)payload[i];
  }
    if (value== "ON") {
    Serial.println("JA");

   }
  Serial.println();
}

void setup() {
  Serial.begin(9600);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  /* set led as output to control led on-off */
 // pinMode(led, OUTPUT);

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  /* configure the MQTT server with IPaddress and port */
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
  

 
}
void loop() {
 
  
    /* if client was disconnected then try to reconnect again */
  if (!client.connected()) {
    mqttconnect();
  }
  /* this function will listen for incomming 
  subscribed topic-process-invoke receivedCallback */
  client.loop();
  /* we measure temperature every 3 secs
  we count until 3 secs reached to avoid blocking program if using delay()*/

    /* read DHT11/DHT22 sensor and convert to string */
 /*   temperature_1=sensors.getTempC(Probe01);
    temperature_2=sensors.getTempC(Probe02);


    
    snprintf (msg, 7, "%lf", temperature_1);*********************************************************** */
      /* publish the message */
    client.publish(TEMP_TOPIC_WATER, "Hello World"); //client.publish(TEMP_TOPIC_WATER, msg);
    
  //  snprintf (msg, 7, "%lf", temperature_2);
      /* publish the message */
    client.publish(TEMP_TOPIC_AIR, "Hello World");
    client.publish(TEMP_TOPIC_LWT, "online");
    client.subscribe(TEMP_TOPIC_SUBSCRIBE);
    delay(1500);

  
}

By definition a retained message is sent for every subscription. As you subscribe in every loop run you get such a message for every run of the loop.