I was looking at this old question (here) and have a related question.
If I want to create new msgids on messages, can I do that?
For instance, if I get an array of devices and want to start up a process for each of those devices, I don't think I want each of the messages to have the same _msgid.
I can iterate through the list of devices and create a new message for each of them inside a function node.
But how can i change the _msgid?
I tried a few things and so far the _msgid remains stubbornly the same.
It's possible/likely that I don't understand the significance of the _msgid.
Each message would have its own unique payload, related to the device (a uuid).
I just don't want the messages getting mixed up anywhere down the line, so it seemed sensible to have unique _msgid. The messages would flow down into logic flows where the data for each device would be gotten from a db and calculations done, with optional flows based on the logic.
That's more or less why I thought that unique _msgid would be a good idea.
If you assign the uuid to msg.uuid for example you preserve the uniqueness of each message and process them accordingly. This is exactly the same as having unique _msgid.
So with this, and where each device name is a uuid
// Input message:
// msg.payload = ["device1", "device2", "device17", "device10", "device2223"]
// Extract the array of chains from the message payload
var devices = msg.payload;
// Iterate over each chain and send a new message for each
for (var i = 0; i < devices.length; i++) {
var device = devices[i];
// Create a new message object
var newMsg = {
payload: device
}
// Send the new message to the next node
node.send(newMsg);
}
I don't have to worry that the messages get mixed up?
Or should I add something like this?
I tend not to worry too much about the programming paradigm....though I tend not to like Object Oriented unless the objects represent something clearly actually physical, or at least elements in a UI. Otherwise? Not so much.