2020-09-29 22:35:59 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/streadway/amqp"
|
|
|
|
|
|
|
|
"go-rest-api/queue"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestWorkerFunc
|
|
|
|
func main() {
|
|
|
|
amqp := queue.New()
|
|
|
|
q := amqp.DeclareQueue("article_queue_test") //failsafe
|
|
|
|
amqp.Consume(q.Name, callback)
|
|
|
|
}
|
|
|
|
|
|
|
|
func callback(d amqp.Delivery) {
|
|
|
|
log.Println("Received message: ", string(d.Body))
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
log.Println("Finished!")
|
2020-09-30 22:13:46 +02:00
|
|
|
d.Ack(false)
|
2020-09-29 22:35:59 +02:00
|
|
|
}
|