Why not use four variables and then use an XPath with the OR function? You might run into trouble if the four variables become three of five but you might even use an if function if you check first how many variables you have. So something like [ID = $var1 or ID = $var2 or ID = $var3 or ID = $var4].
You can use in Java the createXPathQuery. In your microflow build up the XPath string based on the infinite number of integers. Then pass this string to the Java action that returns a list of those objects. This way it does not matter how many ID's there are and you can just add another OR part to the string.
I would also go with Ronald's solution. Only problem could be that the amount of Id's is not always 4 (is that correct?).
A (dirty) solution could be to hard code a maximum number of Id's. If you have less than your maximum, you can fill the remaining variables with the first id. Your 'or' xpath does nit care about duplicates and only returns the result once.
I don’t think this is possible by the retrieve action.
OQL will be effective but sensitive for changes in the domain model.
Another workaround is to create an export and import mapping where you define the attribute as key attribute to retrieve the desired set of objects.