Skip to content

Commit

Permalink
Add the method of graceful exit of consumption and the function of co…
Browse files Browse the repository at this point in the history
…nsumer retrying 3 times by default
  • Loading branch information
lymallor committed Jul 14, 2022
1 parent 67084ce commit 9298290
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions consumers/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/ysk229/go-rabbitmq/connections"
"github.com/ysk229/go-rabbitmq/lib"
"log"
"os"
"syscall"
"testing"
"time"
)
Expand Down Expand Up @@ -120,6 +122,16 @@ func TestGracefulShutdownConsumer(t *testing.T) {
)
}()

go func() {
time.Sleep(5 * time.Second)
p, _ := os.FindProcess(os.Getpid())
log.Println(p.Pid)
err := p.Signal(syscall.SIGINT)
if err != nil {
log.Fatalln(err)
}
}()

c.GracefulShutdown()
}
func TestConcurrentConsumer(t *testing.T) {
Expand Down

0 comments on commit 9298290

Please sign in to comment.