Skip to content

Commit e78e49d

Browse files
committed
add retry logic to checkQueue
1 parent 3893571 commit e78e49d

6 files changed

Lines changed: 49 additions & 10 deletions

File tree

OpenFlow/src/amqpwrapper.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as retry from "async-retry";
12
import * as winston from "winston";
23
import * as amqplib from "amqplib";
34
import { Util } from "./Util";
@@ -437,13 +438,37 @@ export class amqpwrapper {
437438
return q;
438439
}
439440
async checkQueue(queuename: string): Promise<boolean> {
440-
try {
441+
var result: boolean = false;
442+
result = await retry(async bail => {
441443
var queue = await this.getqueue(Config.amqp_url, '/', queuename);
442-
if (queue.consumers == 0) return false;
443-
return true;
444-
} catch (error) {
445-
return false;
444+
let hasConsumers: boolean = false;
445+
if (queue.consumers > 0) {
446+
hasConsumers = true;
447+
}
448+
if (!hasConsumers) {
449+
if (queue.consumer_details != null && queue.consumer_details.length > 0) {
450+
// console.log(queue.consumer_details[0]);
451+
hasConsumers = true;
452+
}
453+
}
454+
if (hasConsumers == false) {
455+
throw new Error("No consumer listening at " + queuename);
456+
// return bail();
457+
}
458+
return hasConsumers;
459+
}, {
460+
retries: 5,
461+
minTimeout: 500,
462+
maxTimeout: 500,
463+
onRetry: function (error: Error, count: number): void {
464+
result = false;
465+
console.log("retry " + count + " error " + error.message + " getting " + url);
466+
}
467+
});
468+
if (result == true) {
469+
return result;
446470
}
471+
return false;
447472
}
448473
async getvhosts(amqp_url) {
449474
var q = this.parseurl(amqp_url);

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openflow-nodered",
3-
"version": "1.0.41",
3+
"version": "1.0.42",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.41
1+
1.0.42

gulpfile.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,27 @@ gulp.task("bumpconfigmap", function () {
9393
gulp.task("bumpaiotfrontend", function () {
9494
var version = "0.0.1";
9595
version = fs.readFileSync("../aiot-frontend/VERSION", "utf8");
96-
9796
console.log('cloudhack/aiot-frontend:' + version);
9897
return gulp.src(["config/**/controllers.yml"])
9998
.pipe(replace(/aiot-frontend:\d+(\.\d+)+/g, 'aiot-frontend:' + version))
10099
.pipe(gulp.dest("config"));
101100
});
101+
gulp.task("bumpprojectfiles", function () {
102+
var data = require("./package.json");
103+
console.log(data.version + " updated to " + version);
104+
data.version = version;
105+
var json = JSON.stringify(data, null, 2);
106+
fs.writeFileSync("package.json", json);
107+
108+
data = require("./OpenFlowNodeRED/package.json");
109+
console.log(data.version + " updated to " + version);
110+
data.version = version;
111+
json = JSON.stringify(data, null, 2);
112+
fs.writeFileSync("OpenFlowNodeRED/package.json", json);
113+
return gulp.src('.');
114+
115+
});
102116

103-
gulp.task("bump", gulp.series("bumpflow", "bumpnodered", "bumpconfigmap", "bumpaiotfrontend"));
117+
gulp.task("bump", gulp.series("bumpflow", "bumpnodered", "bumpconfigmap", "bumpaiotfrontend", "bumpprojectfiles"));
104118

105119
gulp.task("default", gulp.series("copyfiles1", "watch"));

openflow-1.0.4.tgz

-2.63 MB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openiap",
3-
"version": "1.0.41",
3+
"version": "1.0.42",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)