4 Replies Latest reply on Sep 12, 2017 11:57 AM by psavi RSS
    psavi Newbie

    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?

      • Re: MQTT Thing register data multiple times.
        adamr Creator

        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,


          • Re: MQTT Thing register data multiple times.
            psavi Newbie

            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?

              • Re: MQTT Thing register data multiple times.
                adamr Creator

                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.