inceptum
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -30,3 +30,2 @@ import { Connection, Channel } from 'amqplib'; | ||
arguments?: any; | ||
prefetch?: number; | ||
} | ||
@@ -33,0 +32,0 @@ export interface RepliesConsume { |
@@ -0,1 +1,2 @@ | ||
import { ConsumeOptions } from './RabbitmqClient'; | ||
export declare enum RabbitmqBackPressureStrategy { | ||
@@ -30,3 +31,4 @@ ERROR = 0, | ||
messageHandler?: string; | ||
options?: object; | ||
prefetch?: number; | ||
options?: ConsumeOptions; | ||
} |
import { Counter, Histogram } from 'prom-client'; | ||
import { RabbitmqClient } from './RabbitmqClient'; | ||
import { RabbitmqConsumerConfig, RabbitmqClientConfig } from './RabbitmqConfig'; | ||
import { ConsumeOptions, RepliesConsume } from './RabbitmqClient'; | ||
import { RepliesConsume } from './RabbitmqClient'; | ||
import { RabbitmqConsumerHandler, Message } from './RabbitmqConsumerHandler'; | ||
@@ -13,3 +13,3 @@ export declare class RabbitmqConsumer extends RabbitmqClient { | ||
protected messageHandler: RabbitmqConsumerHandler; | ||
constructor(clientConfig: RabbitmqClientConfig, name: string, consumerConfig: any, handler: RabbitmqConsumerHandler); | ||
constructor(clientConfig: RabbitmqClientConfig, name: string, consumerConfig: RabbitmqConsumerConfig, handler: RabbitmqConsumerHandler); | ||
init(): Promise<void>; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
subscribe(queueName: string, consumeOptions?: ConsumeOptions): Promise<RepliesConsume>; | ||
subscribe(queueName: string, consumerConfig: RabbitmqConsumerConfig): Promise<RepliesConsume>; | ||
handleMessage(message: Message): Promise<void>; | ||
@@ -22,0 +22,0 @@ sendMessageToDlq(message: Message): void; |
@@ -64,3 +64,3 @@ "use strict"; | ||
await super.init(); | ||
await this.subscribe(this.consumerConfig.appQueueName, this.consumerConfig.options); | ||
await this.subscribe(this.consumerConfig.appQueueName, this.consumerConfig); | ||
} | ||
@@ -77,9 +77,9 @@ catch (e) { | ||
*/ | ||
async subscribe(queueName, consumeOptions = {}) { | ||
if (consumeOptions.prefetch && consumeOptions.prefetch > 0) { | ||
this.channel.prefetch(consumeOptions.prefetch); | ||
async subscribe(queueName, consumerConfig) { | ||
if (consumerConfig.prefetch && consumerConfig.prefetch > 0) { | ||
this.channel.prefetch(consumerConfig.prefetch); | ||
} | ||
return await this.channel.consume(queueName, (message) => { | ||
this.handleMessage(message); | ||
}, consumeOptions); | ||
}, consumerConfig.options); | ||
} | ||
@@ -86,0 +86,0 @@ async handleMessage(message) { |
{ | ||
"name": "inceptum", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "hipages take on the foundational library for enterprise-grade apps written in NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
430649
6513