Is is best practice to use MNI's in appian , if we need to avoid this could suggest me the ways to so ?
I am generating a pdf file for each record in an array of data records and using MNI on the "Generate PDF from Template" smart service for this to iterate through the array. There may be 1 to 10 records at any time in the array when it is invoked. Also I am setting the instances to run one at a time. I don't see any performance issues. I am using MNI only because it is convenient. Is this a bad idea from a design perspective? Should I replace with an XOR gateway?
No, I wouldn't go with an XOR loop - this is a reasonable case for MNI usage, as long as you don't end up with problems storing your generated documents into a PV.
Yeah keep in mind that an XOR loop is actually worse than using MNI. Part of the reason MNI is often not recommended is that it requires Appian to store execution information for each time the node executes. If you end up with a node running 500 times, this can end up being quite a bit of data. However, using an XOR loop is worse because now you have to run your node 500 times AND run the XOR gateway 500 times. So generally the recommendation is try a!forEach() first - if you can't use that, use MNI, and use an XOR looping flow as a last resort.
In general, MNI isn't a BAD practice or something to AVOID or anything like that.
It's simply just SLOW and limited to only 1000 iterations.
Looping can be a good alternative at times, if it makes more sense for your process model. In general I would use looping when I expect several operations, not just one, to be done on each item in sequence. If it's something where I need to run script task A, script task B, and write to database node C, and then run all three on the next record, and the next after that. If it's impossible to do those steps out of order and get the correct result, I would loop. Looping also has the same limitation of 1000 iterations. It's also just as SLOW if not a little slower.
a!forEach has 2 advantages. It's FAST, maybe even several hundred times as fast. It's limited to 1,000,000 iterations! It has 3 severe limitations though. First, it can only do expression rules. If appain hasn't ported the smart service node you need to an expression rule yet, you can't a!forEach a solution. Second, you have to code all the logic; you can't model it. If it needs a looping or branching structure to it's logic, one that you could easily model in the process modeler, but one that you can't wrap your head around making a rule for, it's going to be painful to make an a!forEach for the solution. Third, you can't a!forEach a subprocess. a!startProcess is restricted from working in any looping functions.
If you got an MNI working and the performance isn't a problem, congratulations! Don't do anything.
If you got an MNI working and the performance is a problem, try to determine if it would be worth taking a crack at replacing it with an a!forEach, or just optimizing the MNI or loop. If both seem about equally feasible, go with the a!forEach.
Discussion posts and replies are publicly visible
© 2019 Appian. All rights reserved.