func (redisServer *RedisInputServer) Start() error { log.Printf("Starting Redis input on input queue: %s, working queue: %s", redisServer.config.InputQueue, redisServer.config.InputQueue+"_working") port := strconv.Itoa(redisServer.config.Port) // Create Redis queue queue := redismq.CreateQueue(redisServer.config.Host, port, redisServer.config.Password, redisServer.config.Db, redisServer.config.InputQueue) consumer, err := queue.AddConsumer(redisServer.config.InputQueue + "_working") if err != nil { log.Println("Error opening Redis input") return err } go redisGet(redisServer, consumer) for { select { case <-redisServer.term: log.Println("Redis input server received term signal") return nil } } return nil }
func main() { testQueue := redismq.CreateQueue("localhost", "6379", "", 9, "clicks") for i := 0; i < 10; i++ { testQueue.Put("testpayload") } consumer, err := testQueue.AddConsumer("testconsumer") if err != nil { panic(err) } for i := 0; i < 10; i++ { p, err := consumer.Get() if err != nil { fmt.Println(err) continue } fmt.Println(p.CreatedAt) err = p.Ack() if err != nil { fmt.Println(err) } } }