MCPcopy
hub / github.com/nestjs/nest / setupChannel

Method setupChannel

packages/microservices/client/client-rmq.ts:203–243  ·  view source on GitHub ↗
(channel: Channel, resolve: Function)

Source from the content-addressed store, hash-verified

201 }
202
203 public async setupChannel(channel: Channel, resolve: Function) {
204 const prefetchCount =
205 this.getOptionsProp(this.options, 'prefetchCount') ||
206 RQM_DEFAULT_PREFETCH_COUNT;
207 const isGlobalPrefetchCount =
208 this.getOptionsProp(this.options, 'isGlobalPrefetchCount') ||
209 RQM_DEFAULT_IS_GLOBAL_PREFETCH_COUNT;
210
211 if (!this.options.wildcards && this.options.exchangeType !== 'fanout') {
212 if (!this.noAssert) {
213 await channel.assertQueue(this.queue, this.queueOptions);
214 }
215
216 if (this.options.exchange && this.options.routingKey) {
217 await channel.bindQueue(
218 this.queue,
219 this.options.exchange,
220 this.options.exchangeType === 'fanout' ? '' : this.options.routingKey,
221 );
222 }
223 } else {
224 const exchange = this.getOptionsProp(
225 this.options,
226 'exchange',
227 this.options.queue,
228 );
229 const exchangeType = this.getOptionsProp(
230 this.options,
231 'exchangeType',
232 'topic',
233 );
234 await channel.assertExchange(exchange, exchangeType, {
235 durable: true,
236 arguments: this.getOptionsProp(this.options, 'exchangeArguments', {}),
237 });
238 }
239
240 await channel.prefetch(prefetchCount, isGlobalPrefetchCount);
241 await this.consumeChannel(channel);
242 resolve();
243 }
244
245 public async consumeChannel(channel: Channel) {
246 const noAck = this.getOptionsProp(this.options, 'noAck', RQM_DEFAULT_NOACK);

Callers 3

createChannelMethod · 0.95
client-rmq.spec.tsFile · 0.45
server-rmq.spec.tsFile · 0.45

Calls 1

consumeChannelMethod · 0.95

Tested by

no test coverage detected