Initial commit
This commit is contained in:
51
cmd/fillqueue/main.go
Normal file
51
cmd/fillqueue/main.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bitbucket.org/outfrontmedia/vendor-scheduler-service-golang/internal/pkg/onexqueue"
|
||||
"encoding/json"
|
||||
"github.com/streadway/amqp"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defer func(start time.Time) {
|
||||
elapsed := time.Since(start)
|
||||
log.Printf("fillqueue.main took %s", elapsed)
|
||||
}(time.Now())
|
||||
|
||||
conn, ch := onexqueue.Connect(os.Getenv("ONEX_QUEUE_URL"))
|
||||
defer conn.Close()
|
||||
defer ch.Close()
|
||||
|
||||
queue := onexqueue.CreateQueueIfNecessary(ch, "hello")
|
||||
|
||||
for i := 1; i <= 15000; i++ {
|
||||
message := &onexqueue.Message{
|
||||
Vendor: "vistar",
|
||||
Params: onexqueue.MessageParams{
|
||||
Player: "79102Z02000392500033J2000",
|
||||
VenueId: "AT0000112",
|
||||
DisplayTime: time.Now().Unix(),
|
||||
DisplayArea: onexqueue.DisplayAreaParam{
|
||||
Width: 600,
|
||||
Height: 900,
|
||||
},
|
||||
},
|
||||
}
|
||||
body, _ := json.Marshal(message)
|
||||
err := ch.Publish(
|
||||
"", // exchange
|
||||
queue.Name, // routing key
|
||||
false, // mandatory
|
||||
false, // immediate
|
||||
amqp.Publishing{
|
||||
ContentType: "application/json",
|
||||
Body: body,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to publish a message: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user