Beispiel #1
0
func main() {

	dbAddress := util.GetKeyValue("RethinkDB", "address")

	var err error
	session, err = db.Connect(db.ConnectOpts{
		Address:  dbAddress,
		Database: "travelPlanning",
	})
	if err != nil {
		log.Fatalln(err.Error())
	}
	log.Println("Connected to db on: " + dbAddress)

	tasks := mq.NewMQ()
	tasks.NewQueue("TripWorkerQueue", "Trip")
	msgs := tasks.GetMessages("TripWorkerQueue")

	forever := make(chan bool)

	go func() {
		for d := range msgs {
			var message mq.Message
			json.Unmarshal(d.Body, &message)
			processMessage(&message)
			tasks.PublishMessage(message, d.ReplyTo, d.CorrelationId, "")
		}
	}()

	log.Printf(" [*] Awaiting for requests")
	<-forever

}
Beispiel #2
0
func main() {
	log.Println("Connected to db on: " + util.GetKeyValue("RethinkDB", "address"))

	tasks := mq.NewMQ()
	tasks.NewQueue("UserWorkerQueue", "User")
	msgs := tasks.GetMessages("UserWorkerQueue")

	var message mq.Message

	forever := make(chan bool)

	go func() {
		for d := range msgs {
			json.Unmarshal(d.Body, &message)
			processMessage(&message)
			tasks.PublishMessage(message, d.ReplyTo, d.CorrelationId, "")
		}
	}()

	log.Printf(" [*] Awaiting for requests")
	<-forever

}