Stored Variables vs messages

Hi,

I am after some advice/help. I have searched various terms and can't find what I am looking for, probably using wrong terms, but here goes!

Does passing messages between nodes cost any extra resources, or is it better to save as a variable and then use a 'get' to reload it?

Although I have no reason to say this, I would imagine that a message, such as 'msg.whatever' is basically a variable that is accessed using the 'msg.whatever' label. The only difference I can see this making is if you wish to read the complete message topic in a debug node.

Or, perhaps I might be breaking some programming protocol?

Look forward to your comments.

Best wishes,

In general you should keep your data on the message as it passes through the flow.

If you use the context store to save data with each message then you'll hit issues when you have more than one message passing through the flow at the same time.

Messages do not physically move as they are passed down the flow. The message stays in one place and just a reference to it is passed down. So there is no benefit to saving in context, at least none that I can think of.

1 Like

Thank you for that, just simplified my code with all the 'set' and 'get' instructions removed. Couldn't see the point of doing it twice!

I do like using this tool. It makes this amateur start to look really professional in the eyes of many, even 'proper programmers'!

1 Like