From d74ead22c5dd0025d9a5205c4c1f6278d56b791c Mon Sep 17 00:00:00 2001 From: Albin Suresh Date: Wed, 5 Mar 2025 08:03:26 +0000 Subject: [PATCH] refactor: Delay after publishing entity creation message Introduce a delay after the entity registration is converted and published to C8Y, to allow it to be processed by the cloud before sending any data messages. This reduces the probability of the data message racing with the registration message and auto-creating the target entity before the registration is processed. --- crates/extensions/c8y_mapper_ext/src/actor.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/extensions/c8y_mapper_ext/src/actor.rs b/crates/extensions/c8y_mapper_ext/src/actor.rs index 4ecdc7ce0a1..ea1b39d1c96 100644 --- a/crates/extensions/c8y_mapper_ext/src/actor.rs +++ b/crates/extensions/c8y_mapper_ext/src/actor.rs @@ -181,6 +181,9 @@ impl C8yMapperActor { self.process_registration_message(pending_entity.reg_message) .await?; + // Wait for a while to allow the registration message to be processed by the cloud before sending the data messages + tokio::time::sleep(Duration::from_secs(1)).await; + // Convert and publish cached data messages for pending_data_message in pending_entity.data_messages { self.process_message(pending_data_message).await?;