func ProcessMessage(msgID string) {
	logrus.Debugf("processing message %s", msgID)

	// Set the message in the scoreboard, so we know this message is being processed.
	AddToScoreboard(message.SectionProcessing, msgID)
	defer func() {
		RemoveFromScoreboard(message.SectionProcessing, msgID)
	}()

	// Check header and get recipient
	header, err := message.GetMessageHeader(message.SectionProcessing, msgID)
	if err != nil {
		// cannot read header.. Let's move to retry queue
		logrus.Warnf("cannot find or read header for message %s. Retrying.", msgID)
		MoveToRetryQueue(msgID)
		return
	}

	rs := container.Instance.GetResolveService()
	addrInfo, err := rs.ResolveAddress(header.To.Addr)
	if err != nil {
		logrus.Trace(err)
		logrus.Warnf("cannot resolve address %s for message %s. Retrying.", header.To.Addr, msgID)
		MoveToRetryQueue(msgID)
		return
	}

	// Local addresses don't need to be send. They are treated locally
	ar := container.Instance.GetAccountRepo()
	if ar.Exists(header.To.Addr) {
		// Do stuff locally
		logrus.Debugf("Message %s can be transferred locally to %s", msgID, addrInfo.Hash)

		err := deliverLocal(addrInfo, msgID, header)
		if err != nil {
			logrus.Warnf("cannot deliver message %s locally to %s. Retrying.", msgID, header.To.Addr)
			MoveToRetryQueue(msgID)
		}

		return
	}

	// Deliver remote
	err = deliverRemote(addrInfo, msgID, header)
	if err != nil {
		logrus.Warnf("cannot deliver message %s remotely to %s. Retrying.", msgID, header.To.Addr)
		MoveToRetryQueue(msgID)
	}
}
// ProcessMessage will process a message found in the processing queue.
//   * If it's a local address, it will be moved to the local mailbox
//   * If it's a remote address, it will be send to the remote mail server
//   * If things fail, it will be moved to the retry queue, where it will be moved to processed queue later
ProcessMessage will process a message found in the processing queue.
If it's a local address, it will be moved to the local mailbox
If it's a remote address, it will be send to the remote mail server
If things fail, it will be moved to the retry queue, where it will be moved to processed queue later
// ProcessMessage will process a message found in the processing queue . // * If it ' s a local address it will be moved to the local mailbox // * If it ' s a remote address it will be send to the remote mail server // * If things fail it will be moved to the retry queue where it will be moved to processed queue later
func ProcessMessage(msgID string) {
	logrus.Debugf("processing message %s", msgID)
	AddToScoreboard(message.SectionProcessing, msgID)
	defer func() {
		RemoveFromScoreboard(message.SectionProcessing, msgID)
	}()
	header, err := message.GetMessageHeader(message.SectionProcessing, msgID)
	if err != nil {
		logrus.Warnf("cannot find or read header for message %s. Retrying.", msgID)
		MoveToRetryQueue(msgID)
		return
	}
	rs := container.Instance.GetResolveService()
	addrInfo, err := rs.ResolveAddress(header.To.Addr)
	if err != nil {
		logrus.Trace(err)
		logrus.Warnf("cannot resolve address %s for message %s. Retrying.", header.To.Addr, msgID)
		MoveToRetryQueue(msgID)
		return
	}
	ar := container.Instance.GetAccountRepo()
	if ar.Exists(header.To.Addr) {
		logrus.Debugf("Message %s can be transferred locally to %s", msgID, addrInfo.Hash)
		err := deliverLocal(addrInfo, msgID, header)
		if err != nil {
			logrus.Warnf("cannot deliver message %s locally to %s. Retrying.", msgID, header.To.Addr)
			MoveToRetryQueue(msgID)
		}
		return
	}
	err = deliverRemote(addrInfo, msgID, header)
	if err != nil {
		logrus.Warnf("cannot deliver message %s remotely to %s. Retrying.", msgID, header.To.Addr)
		MoveToRetryQueue(msgID)
	}
}
func ProcessMessage ( msgID string ) { logrus . Debugf ( " " , msgID ) AddToScoreboard ( message . SectionProcessing , msgID ) defer func ( ) { RemoveFromScoreboard ( message . SectionProcessing , msgID ) } ( ) header , err := message . GetMessageHeader ( message . SectionProcessing , msgID ) if err != nil { logrus . Warnf ( " " , msgID ) MoveToRetryQueue ( msgID ) return } rs := container . Instance . GetResolveService ( ) addrInfo , err := rs . ResolveAddress ( header . To . Addr ) if err != nil { logrus . Trace ( err ) logrus . Warnf ( " " , header . To . Addr , msgID ) MoveToRetryQueue ( msgID ) return } ar := container . Instance . GetAccountRepo ( ) if ar . Exists ( header . To . Addr ) { logrus . Debugf ( " " , msgID , addrInfo . Hash ) err := deliverLocal ( addrInfo , msgID , header ) if err != nil { logrus . Warnf ( " " , msgID , header . To . Addr ) MoveToRetryQueue ( msgID ) } return } err = deliverRemote ( addrInfo , msgID , header ) if err != nil { logrus . Warnf ( " " , msgID , header . To . Addr ) MoveToRetryQueue ( msgID ) } }
ProcessMessage will process a message found in the processing queue.
ProcessMessage will process a message found in the processing queue .
// Set the message in the scoreboard, so we know this message is being processed. // Check header and get recipient // cannot read header.. Let's move to retry queue // Local addresses don't need to be send. They are treated locally // Do stuff locally // Deliver remote