func pushMessage(q *sqs.Queue, message interface{}) error {

	j, err := json.Marshal(message)
	if err != nil {
		return err
	}

	_, err = q.SendMessage(string(j))
	if err != nil {
		return err
	}

	return nil
}
Exemple #2
0
func (s *SQSClient) handle(message string, q *sqs.Queue) error {
	var res *sqs.SendMessageResponse
	err := Retrier.Retry(func() error {
		// Call sqs.Queue.SendMessage() - initiates a HTTP request.
		var e error
		res, e = q.SendMessage(message)
		return e
	})
	if err != nil {
		return err
	}
	// check md5
	expectedHash := md5.New()
	expectedHash.Write([]byte(message))
	expected := fmt.Sprintf("%x", expectedHash.Sum(nil))
	if expected != res.MD5 {
		return errors.New(fmt.Sprintf("message %s Did Not match expected %s", res.MD5, expected))
	}
	return nil
}