Skip to content

Commit

Permalink
feat(rabbitmq): message expiration property (#373)
Browse files Browse the repository at this point in the history
adds ability to set message expiration when publishing messages

fixes #270
  • Loading branch information
underfisk committed Jan 23, 2022
1 parent 754e1db commit 08e2014
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/rabbitmq/src/amqp/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class AmqpConnection {
replyTo: DIRECT_REPLY_QUEUE,
correlationId,
headers: requestOptions.headers,
expiration: requestOptions.expiration,
}
);

Expand Down Expand Up @@ -385,9 +386,13 @@ export class AmqpConnection {
return;
}

const { replyTo, correlationId, headers } = msg.properties;
const { replyTo, correlationId, expiration, headers } = msg.properties;
if (replyTo) {
await this.publish('', replyTo, response, { correlationId, headers });
await this.publish('', replyTo, response, {
correlationId,
expiration,
headers,
});
}
channel.ack(msg);
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions packages/rabbitmq/src/rabbitmq.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface RequestOptions {
timeout?: number;
payload?: any;
headers?: any;
expiration?: string | number;
}

export interface QueueOptions {
Expand Down

0 comments on commit 08e2014

Please sign in to comment.