cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

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

ranjank
14-Alexandrite

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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5
slangley
23-Emerald II
(To:ranjank)

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

ranjank
14-Alexandrite
(To:slangley)

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.

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

ranjank
14-Alexandrite
(To:Constantine)

@Constantine 

Thank you for your response.

 

Our azure expert changed the format of JSON message and then after some modification in subscription we got our desired result.

 

Cheers!!

slangley
23-Emerald II
(To:slangley)

Hi @ranjank.

 

If one of the previous responses answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Top Tags