forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a separate message pump for messages from upstream (Azure#4481)
The reason of the change is that when there is a big load of messages (from devices/modules), the processing queue can grow long. In this case, if there are messages from upstream (e.g twin result, direct method call), those messages get at the end of the queue and takes some time to process them. This change creates a separate queue for messages from upstream, increasing the reaction time of the system in certain scenarios. The root of the change is in the method ForwardPublish(). This method gets calld by the mqtt library when a message arrives, and this puts the messages into a processing queue and returns immediately (giving back the control to the mqtt library as soon as possible). Now the change checks for messages from upstream (those all start with string "$downstream", and puts them into a separate queue. This separate queue gets processed by a specific processing loop, implemented by UpstreamLoop(). Before this change, there was only a single loop, now there is an UpstreamLoop() and DownstreamLoop(), where UpstreamLoop() processes message coming from upstream. This loop uses a simple message handler class called "BrokeredCloudProxyDispatcher" as all messages from upstream goes through that class. DownstreamLoop() check all available message handlers (including BrokeredCloudProxyDispatcher), because it is not known which handler would process the messages. Note, that it is intentional leaving the BrokeredCloudProxyDispatcher class for DownstreamLoop(), so if some message breaks the convention (not starting with $downstream), that still will be handled.
- Loading branch information
Showing
2 changed files
with
225 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters