Skip to content

Commit

Permalink
Fixed connection cloning (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
if0s authored Mar 27, 2023
1 parent d727743 commit 9c862f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.4.1 (March 27, 2023)
Fixed connection cloning in `Publish` action

## 1.4.0 (March 25, 2023)
* Implemented retry mechanism on connection errors
* Added configuration fields to set retry options
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "AMQP component",
"description": "AMQP Component for async communication with queues and topics",
"version": "1.4.0",
"version": "1.4.1",
"credentials": {
"fields": {
"amqpURI": {
Expand Down
6 changes: 5 additions & 1 deletion lib/actions/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const { AMQPClient } = require('../amqp.js');
let amqpClient;

async function processAction(msg, cfg) {
if (!amqpClient || !amqpClient.connection) { amqpClient = new AMQPClient(cfg, this); }
if (!amqpClient || !amqpClient.connection) {
amqpClient = new AMQPClient(cfg, this);
await amqpClient.init();
}

amqpClient.setLogger(this.logger);

let data;
Expand Down
1 change: 0 additions & 1 deletion lib/amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class AMQPClient {
}

async publish(routingKey, content, options) {
await this.init();
this.logger.info('Going to publish message');
await this.channel.publish(this.cfg.topic, routingKey, content, options);
this.logger.info('Message published');
Expand Down
2 changes: 2 additions & 0 deletions spec/actions/publush.spec.js → spec/actions/publish.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('processAction', () => {
const configuration = {
doNotEncrypt: true,
};
sinon.stub(AMQPClient.prototype, 'init').callsFake(async () => { });
const publishStub = sinon.stub(AMQPClient.prototype, 'publish').callsFake(async () => { });
const result = await process.call(getContext(), message, configuration);

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

Expand Down

0 comments on commit 9c862f0

Please sign in to comment.