0

When a consumer from a group xread a stream entry, it will go to the consumer pending entry and as far as I know, it could be removed from the PEL either the consumer do XACK or it is XCLAIM/XAUTOCLAIM by another consumer.

Though my question, if the original consumer died after reading the entry without sending XACK, is there a way to retrieve(?) or change it's status back to unprocessed, so when a consumer read the stream it was given to that consumer. or is the only way by claiming it to another consumer?

because XCLAIM can only be done if we know who's the consumer right? and in this case, i was hoping i could just change the status of the entry to unprocessed, so new consumer can read it

I'm new to Redis, so any thought would be appreciated :) thankyou

dibii
  • 7
  • 5

1 Answers1

0

if the original consumer died after reading the entry without sending XACK, is there a way to retrieve(?) or change it's status back to unprocessed

No, there isn't: once in the PEL, entries can only be pointed to another consumer but can't be released as if they were never read.

because XCLAIM can only be done if we know who's the consumer right?

Indeed, but you could have a special consumer which, within a single LUA script to guarantee atomicity:

  1. XCLAIMs pending entries based on certain criteria (e.g. idle time) and assigns them to itself;
  2. XREADGROUPs them from the PEL;
  3. XADDs them back to the original stream; and,
  4. XACKs the entries read in step 2.

I would consider this sequence of commands overkill for most scenarios I can think of and I would suggest to avoid using it. But it would allow to re-read and re-assign a copy of the entries which were in the PEL to other consumers as they XREADGROUP them.

Efran Cobisi
  • 6,138
  • 22
  • 22
  • Thankyou, I understand, so it wont be possible without sacrificing some stuff... and we can actually xreadgroup PEL? or was it like workaround to read from PEL? – dibii Nov 30 '22 at 09:38
  • Yes, you can use `XREADGROUP` to read the PEL - from the [docs](https://redis.io/commands/xreadgroup/) "any other valid ID or incomplete ID (just the millisecond time part), will have the effect of returning entries that are pending for the consumer sending the command with IDs greater than the one provided." – Efran Cobisi Nov 30 '22 at 20:03
  • Thanks a lot, I'll try ur suggestion, though im not sure if im really going to implement it, but it helps. – dibii Dec 01 '22 at 02:11