@team-supercharge/nest-amqp
Version:
AMQP 1.0 module for Nest framework
75 lines (74 loc) • 2.5 kB
TypeScript
import { EventContext } from 'rhea-promise';
/**
* Class to manage the state of a message transfer and it's status.
*
* @public
*/
export declare class MessageControl {
private readonly context;
/**
* Indicate if the message has already been processed.
* If it is, do not process it again.
*
* @private
* @property
*/
private handled;
/**
* @constructor
* @param {EventContext} context Event context received from Rhea related to the message
*/
constructor(context: EventContext);
/**
* Use `accept` when message has been handled normally.
*
*
* NOTE: When no explicit `accept` / `reject` / `release` call has been made
* in the callback, message will be automatically accepted.
*/
accept(): void;
/**
* Use `reject` when message was unprocessable. It contained either malformed
* or semantically incorrect data. In other words it can't be successfully
* processed in the future without modifications.
*
* NOTE: With ActiveMQ `reject` will result in the same retry cycle as the
* `release` settlement due to technical limitations. Regardless, please
* always use the appropriate settlement.
*
* @param {string|object} reason reason to reject message
*/
reject(reason: string | Record<string, any>): void;
/**
* Use release when a temporary problem happened during message handling, e.g.
* could not save record to DB, 3rd party service errored, etc. The message is
* not malformed and theoretically can be processed at a later time without
* modifications.
*
* NOTE: with ActiveMQ `release` will result in the same retry cycle as the
* `reject` settlement due to technical limitations. Regardless, please
* always use the appropriate settlement.
*/
release(): void;
/**
* Tells you whether the message has already been processed or not.
*
* @return {boolean} The message has already been processed or not
*/
isHandled(): boolean;
/**
* Marking Message as handled, signaling that we are ready for the next message
*
* @private
*/
private handleSettlement;
/**
* AMQ can only handle string reason messages, need to parse the message
*
* @param {string | object} reason Reason for rejecting the message
* @returns {string} parsed message
*
* @private
*/
private getRejectReason;
}