Skip to content

bryanaustin/nsqkeepalive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSQ Keep Alive

Go Reference

By default NSQ will requeue a message if there is no response after 1 minute. This library will touch the message on a regular interval (I use 50 seconds) to let NSQ know it's still being processed.

Example

package main

import (
  "github.com/bryanaustin/nsqkeepalive"
  "github.com/nsqio/go-nsq"
  "time"
)

func main() {
  nsqconfig := nsq.NewConfig()
  consumer, err = nsq.NewConsumer("topic", "channel", nsqconfig)
  if err != nil {
    // Handle err
  }
  handlerobj := nsq.HandlerFunc(handler)
  wrappedhandler := nsqkeepalive.Handler(time.Second * 50, handlerobj)
  consumer.AddHandler(wrappedhandler)
  err = consumer.ConnectToNSQLookupd("localhost:4161")
  if err != nil {
    // Handle err
  }
  // ...
}

func handler(m *nsq.Message) error {
  // This message will be touched until it returns
}

About

Keep alive (touch) NSQ messages on a fixed interval

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages