import * as amqp from 'amqplib' ; import { Options } from 'amqplib/properties' ; import { AmqpChannelService } from '../service/amqp/amqp-channel-service' ; import { AmqpConfirmChannelService } from '../service/amqp/amqp-confirm-channel-service' ; /**
 * Amqp Original Consumer Wrapper
 */ export class AmqpOriginalConsumerWrapper { public readonly consumerName : string ; private readonly parentService : AmqpChannelService | AmqpConfirmChannelService ; param { string } consumerName param { AmqpChannelService } parentService param { string } queue param { ( msg : ( ConsumeMessage | null ) ) => void } processor param { Options . Consume } options constructor ( consumerName , parentService , queue , processor , options ? ) { this . consumerName = consumerName ; this . parentService = parentService ; this . parentService . logger . info ( `Creating Consumer ${ this . consumerName }` ) ; const currentOptions = Object . assign ( { consumerTag : consumerName } , options ) ; this . parentService . currentChannelInstance . consume ( queue , processor , currentOptions ) . catch ( err => { this . parentService . logger . error ( `Can't Create Consumer ${ this . consumerName } Error: ${ err . stack }` ) ; throw err ; } ) ; } return { Promise < void > } public async kill ( ) { await this . parentService . currentChannelInstance . cancel ( this . consumerName ) ; this . parentService . logger . warn ( `Killed Consumer ${ this . consumerName }` ) ; } }