0

I am using redis stream and XReadGroup for reading messages from stream. I have set block parameter as 0. currently my code look like this

data, err := w.rdb.XReadGroup(ctx, &redis.XReadGroupArgs{
            Group:    w.opts.group,
            Consumer: w.opts.consumer,
            Streams:  []string{w.opts.streamName, ">"},
            Count: 1,
            Block: 0,
        }).Result()

I am currently facing a problem that if I keep the application (involving this code) idle for 10-12 hours, XReadGroup is not able to read new messages, if I restart the application then all the new messages consumed at once. Is there any solution for this problem?

1 Answers1

0

You can have a block time of let's say 10s, it does not change anything (I guess the code you provided is in a while(true)).

From my experience you can keep the app idle for days and it still works.

I don't really know why but I guess it has to do with the "constant" back and forth "reseting" the connection.

JeanJacquesGourdin
  • 1,496
  • 5
  • 25