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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

MQTT Thing register data multiple times.

psavi
7-Bedrock

MQTT Thing register data multiple times.

I have some Things registered on Thingworx, they all have a subscription (defined on the Template) on payload DataChange that change all the other properties based on the payload.

I set QOS on 2 and by default the mqtt thing receive exactly 1 message every minute by the server.

The problem is, when I look at the QueryPropertyHistory i see triple or even quadruple data:

if I send ONE message at 15:30 and look at QueryPropertyHistory I see 3 or 4 events with timestamps at 15:30:00.001, 15:30:00.002, 15:30:00.003.


It's like the subscription happens multiple times for some reason I can't understand.

It's annoying because it takes space for no reason and it's a mess when I bind it to a time chart Widget


Has anyone ever run into this problem too?

ACCEPTED SOLUTION

Accepted Solutions
psavi
7-Bedrock
(To:AdamR)

Hello Adam,

I just found the problem, I was updating property values on the subscription using this format:


me.lat = x;

me.long = y;

so every time a property changed a new event was added.

Is there a way on the subscription to change every property at once?

View solution in original post

4 REPLIES 4
AdamR
14-Alexandrite
(To:psavi)

Hello Piero,

A couple of additional questions that may help us come to an answer.  Is the data in these additional property history records all the same?  Also, what is the setting for the DataChange on the property that is logging the data?  Is it Value, Always,...??

Thank you,

Adam

psavi
7-Bedrock
(To:AdamR)

Hello Adam,

I just found the problem, I was updating property values on the subscription using this format:


me.lat = x;

me.long = y;

so every time a property changed a new event was added.

Is there a way on the subscription to change every property at once?

AdamR
14-Alexandrite
(To:psavi)

Great that you found what the cause was.  Each property is set to have it's own data change event so in this case there is not a way to prevent a subscription from running on each even if you were to set the properties all at once. 

There some functions, like aggragate in the code snippets that could normalize this data when you query it for a chart, but it would still store that many data points. 

The other option is to not use a value steam and create a stream to push the values into in your subscription code.  That way you have full control on what and how data is recorded.

psavi
7-Bedrock
(To:AdamR)

Now it's working, I'm using .UpdatePropertyValues as described here : UpdatePropertyValues service

It's probably not the best way for high performance but it works, I'll try with streams later.

Announcements


Top Tags