Skip to content

Commit

Permalink
Allow delete messages option after acknowledge (#12)
Browse files Browse the repository at this point in the history
* Allow delete message after acknowledge

* Update Readme

* Create node package

* Revert name of package

* Change option name to deleteMessagesAfterAck

* Update Readme
  • Loading branch information
nicoalonso authored Jan 4, 2024
1 parent 79d8a39 commit 2c92416
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async function bootstrap() {
block: 5000,
consumer: 'users-1',
consumerGroup: 'users',
deleteMessagesAfterAck: true, // optional: delete message from stream
},
// optional. See our example main.ts file for more details...
// serialization: {},
Expand Down
1 change: 1 addition & 0 deletions lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface RedisStreamOptionsXreadGroup {
block?: number;
consumerGroup: string;
consumer: string;
deleteMessagesAfterAck?: boolean;
}

export type RedisStreamOptions = RedisStreamOptionsXreadGroup;
Expand Down
7 changes: 7 additions & 0 deletions lib/redis.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ export class RedisStreamStrategy
inboundContext.getMessageId(),
);

if (true === this.options?.streams?.deleteMessagesAfterAck) {
await this.client.xdel(
inboundContext.getStream(),
inboundContext.getMessageId(),
);
}

return true;
} catch (error) {
this.logger.error(error);
Expand Down

0 comments on commit 2c92416

Please sign in to comment.