Skip to content

Commit 9c862f0

Browse files
authored
Fixed connection cloning (#20)
1 parent d727743 commit 9c862f0

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.4.1 (March 27, 2023)
2+
Fixed connection cloning in `Publish` action
3+
14
## 1.4.0 (March 25, 2023)
25
* Implemented retry mechanism on connection errors
36
* Added configuration fields to set retry options

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "AMQP component",
33
"description": "AMQP Component for async communication with queues and topics",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"credentials": {
66
"fields": {
77
"amqpURI": {

lib/actions/publish.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ const { AMQPClient } = require('../amqp.js');
44
let amqpClient;
55

66
async function processAction(msg, cfg) {
7-
if (!amqpClient || !amqpClient.connection) { amqpClient = new AMQPClient(cfg, this); }
7+
if (!amqpClient || !amqpClient.connection) {
8+
amqpClient = new AMQPClient(cfg, this);
9+
await amqpClient.init();
10+
}
11+
812
amqpClient.setLogger(this.logger);
913

1014
let data;

lib/amqp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class AMQPClient {
8888
}
8989

9090
async publish(routingKey, content, options) {
91-
await this.init();
9291
this.logger.info('Going to publish message');
9392
await this.channel.publish(this.cfg.topic, routingKey, content, options);
9493
this.logger.info('Message published');

spec/actions/publush.spec.js renamed to spec/actions/publish.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('processAction', () => {
2626
const configuration = {
2727
doNotEncrypt: true,
2828
};
29+
sinon.stub(AMQPClient.prototype, 'init').callsFake(async () => { });
2930
const publishStub = sinon.stub(AMQPClient.prototype, 'publish').callsFake(async () => { });
3031
const result = await process.call(getContext(), message, configuration);
3132

@@ -49,6 +50,7 @@ describe('processAction', () => {
4950
routingKey: 'test',
5051
},
5152
};
53+
sinon.stub(AMQPClient.prototype, 'init').callsFake(async () => { });
5254
const publishStub = sinon.stub(AMQPClient.prototype, 'publish').callsFake(async () => { });
5355
const result = await process.call(getContext(), message, {});
5456

0 commit comments

Comments
 (0)