Change MessageFactory into an object