AME-11653 Fix slowdown when creating and deleting many realms
AME-11653 Replace use of reflection with listener