@@ -1281,7 +1281,6 @@ private static Message ProcessC2DMessage(MqttApplicationMessageReceivedEventArgs
12811281
12821282 private async Task HandleReceivedMessageAsync ( MqttApplicationMessageReceivedEventArgs receivedEventArgs )
12831283 {
1284- receivedEventArgs . AutoAcknowledge = false ;
12851284 string topic = receivedEventArgs . ApplicationMessage . Topic ;
12861285
12871286 if ( topic . StartsWith ( _deviceBoundMessagesTopic , StringComparison . InvariantCulture ) )
@@ -1300,21 +1299,25 @@ private async Task HandleReceivedMessageAsync(MqttApplicationMessageReceivedEven
13001299 else if ( topic . StartsWith ( TwinDesiredPropertiesPatchTopic , StringComparison . InvariantCulture ) )
13011300 {
13021301 HandleReceivedDesiredPropertiesUpdateRequest ( receivedEventArgs ) ;
1302+ await receivedEventArgs . AcknowledgeAsync ( CancellationToken . None ) ;
13031303 }
13041304 else if ( topic . StartsWith ( TwinResponseTopic , StringComparison . InvariantCulture ) )
13051305 {
13061306 HandleTwinResponse ( receivedEventArgs ) ;
1307+ await receivedEventArgs . AcknowledgeAsync ( CancellationToken . None ) ;
13071308 }
13081309 else if ( topic . StartsWith ( DirectMethodsRequestTopic , StringComparison . InvariantCulture ) )
13091310 {
13101311 HandleReceivedDirectMethodRequest ( receivedEventArgs ) ;
1312+ await receivedEventArgs . AcknowledgeAsync ( CancellationToken . None ) ;
13111313 }
13121314 else if ( topic . StartsWith ( _moduleEventMessageTopic , StringComparison . InvariantCulture )
13131315 || topic . StartsWith ( _edgeModuleInputEventsTopic , StringComparison . InvariantCulture ) )
13141316 {
13151317 // This works regardless of if the event is on a particular Edge module input or if
13161318 // the module is not an Edge module.
13171319 await HandleIncomingEventMessageAsync ( receivedEventArgs ) . ConfigureAwait ( false ) ;
1320+ await receivedEventArgs . AcknowledgeAsync ( CancellationToken . None ) ;
13181321 }
13191322 else if ( Logging . IsEnabled )
13201323 {
@@ -1352,9 +1355,6 @@ private async Task HandleReceivedCloudToDeviceMessageAsync(Message receivedCloud
13521355
13531356 private void HandleReceivedDirectMethodRequest ( MqttApplicationMessageReceivedEventArgs receivedEventArgs )
13541357 {
1355- // This message is always QoS 0, so no ack will be sent.
1356- receivedEventArgs . AutoAcknowledge = true ;
1357-
13581358 byte [ ] payload = receivedEventArgs . ApplicationMessage . Payload . ToArray ( ) ;
13591359
13601360 string [ ] tokens = Regex . Split ( receivedEventArgs . ApplicationMessage . Topic , "/" , RegexOptions . Compiled ) ;
@@ -1372,18 +1372,13 @@ private void HandleReceivedDirectMethodRequest(MqttApplicationMessageReceivedEve
13721372
13731373 private void HandleReceivedDesiredPropertiesUpdateRequest ( MqttApplicationMessageReceivedEventArgs receivedEventArgs )
13741374 {
1375- // This message is always QoS 0, so no ack will be sent.
1376- receivedEventArgs . AutoAcknowledge = true ;
13771375 var twinProperties = JsonConvert . DeserializeObject < TwinCollection > ( Encoding . UTF8 . GetString ( receivedEventArgs . ApplicationMessage . Payload . ToArray ( ) ) , JsonSerializerSettingsInitializer . GetJsonSerializerSettings ( ) ) ;
13781376
13791377 _onDesiredStatePatchListener . Invoke ( twinProperties ) ;
13801378 }
13811379
13821380 private void HandleTwinResponse ( MqttApplicationMessageReceivedEventArgs receivedEventArgs )
13831381 {
1384- // This message is always QoS 0, so no ack will be sent.
1385- receivedEventArgs . AutoAcknowledge = true ;
1386-
13871382 if ( ParseResponseTopic ( receivedEventArgs . ApplicationMessage . Topic , out string receivedRequestId , out int status , out long version ) )
13881383 {
13891384 byte [ ] payloadBytes = receivedEventArgs . ApplicationMessage . Payload . ToArray ( ) ?? Array . Empty < byte > ( ) ;
@@ -1496,8 +1491,6 @@ private void RemoveOldOperations(object state)
14961491
14971492 private async Task HandleIncomingEventMessageAsync ( MqttApplicationMessageReceivedEventArgs receivedEventArgs )
14981493 {
1499- receivedEventArgs . AutoAcknowledge = true ;
1500-
15011494 using var iotHubMessage = new Message ( receivedEventArgs . ApplicationMessage . Payload . ToArray ( ) ) ;
15021495
15031496 // The MqttTopic is in the format - devices/deviceId/modules/moduleId/inputs/inputName
0 commit comments