为什么我在读redis流时得到(零)

fcg9iug3  于 2021-06-10  发布在  Redis
关注(0)|答案(1)|浏览(445)

在我的流中,我有一个挂起的消息:

redis[7]> XREADGROUP GROUP symfony consumer COUNT 1 STREAMS messages 0
1) 1) "messages"
   2) 1) 1) "1592850947048-0"
         2) (nil)
redis[7]> XPENDING messages symfony 
1) (integer) 1
2) "1592850947048-0"
3) "1592850947048-0"
4) 1) 1) "consumer"
      2) "1"

不可能是(零),但还是。。我看到了新消息:

redis[7]> XREADGROUP GROUP symfony consumer COUNT 1 STREAMS messages >
1) 1) "messages"
   2) 1) 1) "1593141769417-0"
         2) 1) "message"
            2) "s:726:\"{\"body\":\"O:36:\\\\\\\"Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Envelope\\\\\\\":2:{s:44:\\\\\\\"\\\\0Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Envelope\\\\0stamps\\\\\\\";a:1:{s:46:\\\\\\\"Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Stamp\\\\\\\\BusNameStamp\\\\\\\";a:1:{i:0;O:46:\\\\\\\"Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Stamp\\\\\\\\BusNameStamp\\\\\\\":1:{s:55:\\\\\\\"\\\\0Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Stamp\\\\\\\\BusNameStamp\\\\0busName\\\\\\\";s:21:\\\\\\\"messenger.bus.default\\\\\\\";}}}s:45:\\\\\\\"\\\\0Symfony\\\\\\\\Component\\\\\\\\Messenger\\\\\\\\Envelope\\\\0message\\\\\\\";O:26:\\\\\\\"App\\\\\\\\Bus\\\\\\\\Message\\\\\\\":2:{s:32:\\\\\\\"\\\\0App\\\\\\\\Bus\\\\\\\\Message\\\\0type\\\\\\\";i:6;s:35:\\\\\\\"\\\\0App\\\\\\\\Bus\\\\\\\\Message\\\\0payload\\\\\\\";a:1:{s:7:\\\\\\\"eventId\\\\\\\";i:83787;}}}\",\"headers\":[]}\";"
redis[7]> XPENDING messages symfony
1) (integer) 2
2) "1592850947048-0"
3) "1593141769417-0"
4) 1) 1) "consumer"
      2) "2"

新消息不是空的,但是如果我读了消息-两者都是(nil)

redis[7]> XREADGROUP GROUP symfony consumer COUNT 2 STREAMS messages 0
1) 1) "messages"
   2) 1) 1) "1592850947048-0"
         2) (nil)
      2) 1) "1593141769417-0"
         2) (nil)

为什么?

6qfn3psc

6qfn3psc1#

127.0.0.1:6379[7]> XADD test-1 MAXLEN 3 * test-field-1 test-message-1
"1593427016468-0"
127.0.0.1:6379[7]> XADD test-1 MAXLEN 3 * test-field-2 test-message-2
"1593427036073-0"
127.0.0.1:6379[7]> XADD test-1 MAXLEN 3 * test-field-3 test-message-3
"1593427043133-0"
127.0.0.1:6379[7]> XGROUP CREATE test-1 test-group 0
OK
127.0.0.1:6379[7]> XREADGROUP GROUP test-group consumer COUNT 1 STREAMS test-1 >
1) 1) "test-1"
   2) 1) 1) "1593427016468-0"
         2) 1) "test-field-1"
            2) "test-message-1"
127.0.0.1:6379[7]> XADD test-1 MAXLEN 3 * test-field-4 test-message-4
"1593427272729-0"
127.0.0.1:6379[7]> XREADGROUP GROUP test-group consumer COUNT 1 STREAMS test-1 0
1) 1) "test-1"
   2) 1) 1) "1593427016468-0"
         2) (nil)

这是redis流的正常行为?redis delete old message body(设置为 nil )即使收到一些消费者的信息。

相关问题