Raise exception when trying to publish an invalid message