func batchSend(values []interface{}) bool { l := len(values) entries := make([]*sqs.SendMessageBatchRequestEntry, l) for i := 0; i < l; i++ { s := strconv.Itoa(i) value := values[i].(*Value) var one sqs.SendMessageBatchRequestEntry one.Id = &s one.MessageBody = (*value).Key var mav sqs.MessageAttributeValue mav.BinaryValue = (*value).V mav.DataType = &binary one.MessageAttributes = make(map[string]*sqs.MessageAttributeValue) one.MessageAttributes[valueName] = &mav entries[i] = &one } params := &sqs.SendMessageBatchInput{ Entries: entries, QueueUrl: &qURL, } if _, err := thisSQS.SendMessageBatch(params); err != nil { log.Println(err) return false } return true }
func (q *QueueInfo) SendMessage(msgString []byte) { var mav sqs.MessageAttributeValue mav.BinaryValue = msgString mav.DataType = &binary var msg sqs.SendMessageInput msg.MessageAttributes = make(map[string]*sqs.MessageAttributeValue) msg.MessageAttributes[valueName] = &mav msg.QueueUrl = q.Queue msg.MessageBody = &body _, err := thisSQS.SendMessage(&msg) if err != nil { fmt.Println(err) } }