Skip to main content
1-Visitor
May 8, 2020
Solved

How to put lock on subscription so that it will not execute until subscription completes work

  • May 8, 2020
  • 5 replies
  • 1944 views

Hi,

 

Actually, I have a use-case in which multiple tags are coming one after one from Azure IoT Hub in one JSON property which is overwriting every time with the property value and timestamp . The property name is populating in some other string property.

 

and my subscription is running on that JSON property.

 

I have to dynamically update all the properties as per JSON data arrives but sometimes what happens that the data of one property gets updated to some other property and hence it results in false data for all the properties.

 

As per my understanding, if somehow I can make this subscription like it will not execute next time until the current execution will not complete then maybe it can solve the issue of assigning false data to properties.

 

Can somebody help with this?

 

Thanks in advance. 

Best answer by Constantine

Hello @ranjank,

 

If you have control over the edge side, you should probably try to put propertyName and Status values into the Value JSON, similar to what you have with SourceTimestamp -- this is the only way I can think of to avoid this issue. I don't believe that synchronizing the subscriptions (to ensure that they don't run in parallel) will help, because their order is not strictly defined.

 

Regards,
Constantine

5 replies

Support
May 8, 2020

Hi @ranjank.

 

It sounds like you may have a coding issue.  However, we're not understanding why a subscription is necessary.  If your configuration is set up correctly, you should be receiving updates from the Azure IoT Hub automatically.

 

How frequently are you receiving updates from your devices?  How many devices are sending updates?

 

Regards.

 

--Sharon

ranjank1-VisitorAuthor
1-Visitor
May 8, 2020

Hi @slangley ,

 

We are getting remote properties like propertyName and Value (i.e. its value) in below format 

 

{
"event": {
"origin": "ABCDevice",
"payload": "{"NodeId":"nsu=KEPServerEX;s=temperature","ApplicationUri":"urn:ABC:Kepware.KEPServerEX.V6:UA%20Server","propertyName":"temperature","Status":"Good","Value":{"Value":45,"SourceTimestamp":"2020-05-01T12:31:01.4608889Z"}}"
}
}

 

After binding remote property in ThingWorx it will look like:-

NodeId-------->nsu=KEPServerEX;s=temperature

ApplicationUri---> urn:ABC:Kepware.KEPServerEX.V6:UA%20Server

propertyName----> temperature

Status-----> Good

Value-------> {"Value":45,"SourceTimestamp":"2020-05-01T12:31:01.4608889Z"}

 

and since there are more than 25 tags (per thing) are coming one by one and overwriting "propertyName" and "Value" we simultaneously we have put the subscription on the Data change event of "Value" property to dynamically create and update the values of property coming in "propertyName".

 

Azure IoT Hub pushes all the tags simultaneously after every 30 seconds.

18-Opal
May 10, 2020

Hello @ranjank,

 

If you have control over the edge side, you should probably try to put propertyName and Status values into the Value JSON, similar to what you have with SourceTimestamp -- this is the only way I can think of to avoid this issue. I don't believe that synchronizing the subscriptions (to ensure that they don't run in parallel) will help, because their order is not strictly defined.

 

Regards,
Constantine