本文整理匯總了Golang中github.com/crowdmob/goamz/sqs.Queue.ReceiveMessage方法的典型用法代碼示例。如果您正苦於以下問題:Golang Queue.ReceiveMessage方法的具體用法?Golang Queue.ReceiveMessage怎麽用?Golang Queue.ReceiveMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/crowdmob/goamz/sqs.Queue
的用法示例。
在下文中一共展示了Queue.ReceiveMessage方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: waitForMessages
func (l *SQSListener) waitForMessages(q *sqs.Queue) {
msgResponse, err := q.ReceiveMessage(1)
if err != nil || len(msgResponse.Messages) < 1 {
time.Sleep(l.PollInterval)
return
}
l.handle(&msgResponse.Messages[0], q)
}
示例2: readFromQueueOnce
func (r *SQSReader) readFromQueueOnce(q *sqs.Queue) error {
r.Logger.Printf("%s: reading messages from queue\n", r.QueueName)
results, err := q.ReceiveMessage(RECV_MAX_MESSAGES)
if err != nil {
return err
}
r.Logger.Printf("%s: read %d messages\n", r.QueueName, len(results.Messages))
for _, message := range results.Messages {
r.enqueueMessage(message.Body, message.ReceiptHandle)
}
return nil
}
示例3: listenOnQueue
func listenOnQueue(q *sqs.Queue, ch chan *sqs.Message) {
for {
resp, err := q.ReceiveMessage(1)
if err != nil {
log.Panic(err)
}
for _, m := range resp.Messages {
ch <- &m
q.DeleteMessage(&m)
}
}
}
示例4: Start
func Start(q *sqs.Queue, h Handler, t time.Duration, receiveMessageNum int, client twilio.Client, sender string) {
fmt.Println(fmt.Sprintf("worker: Start polling [%s]", time.Now().Local()))
for {
resp, err := q.ReceiveMessage(receiveMessageNum)
if err != nil {
log.Println(err)
continue
}
if len(resp.Messages) > 0 {
fmt.Printf("\r")
run(q, h, resp, client, sender)
} else {
fmt.Printf(".")
}
time.Sleep(t)
}
}