Array in "randomize with" constraint is not properly incrementing its index

In reply to Reuben:

This behavior may be because of the post increment operator (msg_id++).
Can you try with msg_id = msg_id + 1; ?