code: public function createMessage(MessageInterface $message)
      {
          // Set post time and persist message.
          $message->setUserId($this->getServiceManager()->get('zfcuser_auth_service')->getIdentity()->getId());
          $message->setTimestampCreated(new \DateTime);
  
          $this->getEventManager()->trigger(
              __FUNCTION__,
              $message,
              array(
                  'message' => $message,
              )
          );
  
          $message = $this->messageMapper->persist($message);
  
          $this->getEventManager()->trigger(
              __FUNCTION__ . '.post',
              $message,
              array(
                  'message' => $message,
              )
          );
          return $message;
      }
docs: createMessage
  
  @param MessageInterface $message
  @return MessageInterface