@emartech/rabbitmq-client
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "3.0.0" | ||
"version": "3.1.0" | ||
} |
@@ -12,2 +12,3 @@ 'use strict'; | ||
this._connectionType = configuration.connectionType || 'default'; | ||
this._onChannelEstablished = configuration.onChannelEstablished || (async () => Promise.resolve()); | ||
this._batchTimeout = configuration.batchTimeout || 1000; | ||
@@ -35,2 +36,3 @@ this._batchSize = configuration.batchSize || 1024; | ||
await this._setupRabbitMqChannel(); | ||
await this._onChannelEstablished(this._rabbitMqChannel); | ||
this._consumer = await this._rabbitMqChannel.consume(this._channel, message => { | ||
@@ -37,0 +39,0 @@ this._inProgress++; |
@@ -76,2 +76,13 @@ 'use strict'; | ||
it('should call onChannelEstablished with channel', async function() { | ||
stubRabbitMq(); | ||
const options = { | ||
onChannelEstablished: sandbox.spy() | ||
}; | ||
await createConsumer(options); | ||
expect(options.onChannelEstablished).have.been.calledOnce; | ||
}); | ||
it('should call onMessages with batched messages', async function() { | ||
@@ -78,0 +89,0 @@ const message1 = createMessage({ content: '{"foo":"bar"}' }); |
@@ -12,2 +12,3 @@ 'use strict'; | ||
this._connectionType = configuration.connectionType || 'default'; | ||
this._onChannelEstablished = configuration.onChannelEstablished || (async () => Promise.resolve()); | ||
this._onMessage = configuration.onMessage; | ||
@@ -31,2 +32,3 @@ this._retryTime = configuration.retryTime || 60000; | ||
await channel.prefetch(this._prefetchCount); | ||
await this._onChannelEstablished(channel); | ||
@@ -33,0 +35,0 @@ channel.on('error', function(err) { |
@@ -88,2 +88,15 @@ 'use strict'; | ||
it('should call onChannelEstablished with channel', async function() { | ||
const options = { | ||
logger: loggerName, | ||
channel: channelName, | ||
onChannelEstablished: sandbox.spy() | ||
}; | ||
const rabbitMQConsumer = RabbitMQConsumer.create(amqpConfig, options); | ||
await rabbitMQConsumer.process(); | ||
expect(options.onChannelEstablished).have.been.calledOnce; | ||
}); | ||
it('should not retry when message is not parsable as JSON', async function() { | ||
@@ -90,0 +103,0 @@ const message = { content: Buffer.from('Not a JSON') }; |
39811
973