Storing partial messages

I have a flow that receives data via the UDP receiver. The data comes in separate packets one after another, for example:

Packet 1 - contains voltage
Packet 2 - contains amps
Packet 3 - contains temp

I want to combine all the data from each packet and write it to a DB as a single record. Where I'm confused is how to store the temporary data for later upload.

I know I can use global variables then use a function to verify they're all loaded, write to the DB then finally clear the global variables so the function logic won't have false triggers. However, I feel like that isn't a good approach as I could end up with outdated data mixed with recent data loaded into the variables.

You would always have the latest, wouldn't you? If you worry about data being outdated, I would introduce a mechanism that warns if data has not been updated within a certain time period. Like having a trigger node for each data type. The node doesn't send anything as long as data is coming in as expected but if it doesn't, it would trigger a message

1 Like

I would do this by setting the topic to different values for the three results and feeding them all into a Join node. Set this to generate key/value pairs and to send its result after three topics received. Then this will pass on a message with all three contents for you to extract the data as required.
If in addition you select Send after each subsequent message then once three have been received it will send a message with the latest values for all three every time a new message is received. You may or may not want that.
One problem if you have not selected that checkbox is what happens if one of the packets is not available, then the whole setup can get out of phase, so a better solution might be to not say to send after three messages but to arrange the flow to send it msg.complete after you have sent it all three.