@platform-x/hep-message-broker-client 1.0.2 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/Util/commonUtil.js.map +1 -0
- package/dist/src/Util/constants.js +8 -0
- package/dist/src/Util/constants.js.map +1 -0
- package/dist/src/Util/logger.js.map +1 -0
- package/dist/src/Util/requestTracer.js.map +1 -0
- package/dist/src/config/ConfigManager.js.map +1 -0
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/index.js +22 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/messageBroker/BaseRabbitMQClient.js.map +1 -0
- package/dist/src/messageBroker/ConnectionManager.js.map +1 -0
- package/dist/src/messageBroker/MessageBrokerClient.js.map +1 -0
- package/dist/src/messageBroker/MessageConsumer.js.map +1 -0
- package/dist/src/messageBroker/MessageProducer.js.map +1 -0
- package/dist/src/messageBroker/RabbitMQClient.js.map +1 -0
- package/dist/src/messageBroker/RetryManager.js.map +1 -0
- package/dist/src/messageBroker/interface/ConnectionWrapper.js.map +1 -0
- package/dist/src/messageBroker/interface/IMessageBrokerClient.js.map +1 -0
- package/dist/src/messageBroker/rabbitmq/MessageBrokerClient.js +4 -1
- package/dist/src/messageBroker/rabbitmq/MessageBrokerClient.js.map +1 -0
- package/dist/src/messageBroker/types/ActionType.js.map +1 -0
- package/dist/src/messageBroker/types/PublishMessageInputType.js.map +1 -0
- package/dist/src/models/MessageModel.js.map +1 -0
- package/dist/src/models/NotificationMessageModel.js.map +1 -0
- package/package.json +43 -40
- package/src/Util/commonUtil.ts +41 -0
- package/src/Util/constants.ts +4 -0
- package/src/Util/logger.ts +219 -0
- package/src/Util/requestTracer.ts +28 -0
- package/src/config/ConfigManager.ts +35 -0
- package/src/config/index.ts +31 -0
- package/src/index.ts +73 -0
- package/src/messageBroker/BaseRabbitMQClient.ts +30 -0
- package/src/messageBroker/ConnectionManager.ts +182 -0
- package/src/messageBroker/MessageBrokerClient.ts +88 -0
- package/src/messageBroker/MessageConsumer.ts +85 -0
- package/src/messageBroker/MessageProducer.ts +142 -0
- package/src/messageBroker/RabbitMQClient.ts +47 -0
- package/src/messageBroker/RetryManager.ts +64 -0
- package/src/messageBroker/interface/ConnectionWrapper.ts +7 -0
- package/src/messageBroker/interface/IMessageBrokerClient.ts +11 -0
- package/src/messageBroker/rabbitmq/MessageBrokerClient.ts +680 -0
- package/src/messageBroker/types/ActionType.ts +1 -0
- package/src/messageBroker/types/PublishMessageInputType.ts +8 -0
- package/src/models/MessageModel.ts +14 -0
- package/tsconfig.json +73 -0
- package/dist/src/Util/commonUtil.d.ts +0 -16
- package/dist/src/Util/logger.d.ts +0 -68
- package/dist/src/Util/requestTracer.d.ts +0 -7
- package/dist/src/config/ConfigManager.d.ts +0 -9
- package/dist/src/config/index.d.ts +0 -29
- package/dist/src/index.d.ts +0 -2
- package/dist/src/messageBroker/BaseRabbitMQClient.d.ts +0 -16
- package/dist/src/messageBroker/ConnectionManager.d.ts +0 -60
- package/dist/src/messageBroker/MessageBrokerClient.d.ts +0 -34
- package/dist/src/messageBroker/MessageConsumer.d.ts +0 -26
- package/dist/src/messageBroker/MessageProducer.d.ts +0 -29
- package/dist/src/messageBroker/RabbitMQClient.d.ts +0 -12
- package/dist/src/messageBroker/RetryManager.d.ts +0 -23
- package/dist/src/messageBroker/interface/ConnectionWrapper.d.ts +0 -6
- package/dist/src/messageBroker/interface/IMessageBrokerClient.d.ts +0 -7
- package/dist/src/messageBroker/rabbitmq/MessageBrokerClient.d.ts +0 -122
- package/dist/src/messageBroker/types/ActionType.d.ts +0 -1
- package/dist/src/messageBroker/types/PublishMessageInputType.d.ts +0 -7
- package/dist/src/models/MessageModel.d.ts +0 -5
- /package/{dist/src/models/NotificationMessageModel.d.ts → src/models/NotificationMessageModel.ts} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
class MessageModel {
|
|
3
|
+
message: object | string;
|
|
4
|
+
// corelationId: string;
|
|
5
|
+
// version: number;
|
|
6
|
+
// trace: string | undefined;
|
|
7
|
+
constructor(message: object | string) {
|
|
8
|
+
this.message = message;
|
|
9
|
+
// this.corelationId = '';
|
|
10
|
+
// this.version = 0.1;
|
|
11
|
+
// this.trace = '';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default MessageModel;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
|
|
8
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
+
"lib": ["es6"], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
13
|
+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "dist", /* Redirect output structure to the directory. */
|
|
18
|
+
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
|
44
|
+
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
45
|
+
|
|
46
|
+
/* Module Resolution Options */
|
|
47
|
+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
48
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
49
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
50
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
51
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
52
|
+
"types": ["jest","node","reflect-metadata"], /* Type declaration files to be included in compilation. */
|
|
53
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
54
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
55
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
56
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
57
|
+
|
|
58
|
+
/* Source Map Options */
|
|
59
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
60
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
62
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
63
|
+
|
|
64
|
+
/* Experimental Options */
|
|
65
|
+
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
66
|
+
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
67
|
+
|
|
68
|
+
/* Advanced Options */
|
|
69
|
+
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
70
|
+
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
71
|
+
"resolveJsonModule": true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* stringToBase64 - to convert string into base64
|
|
3
|
-
* @param {string} toEncode- string request
|
|
4
|
-
*/
|
|
5
|
-
export declare const stringToBase64: (toEncode: string) => string;
|
|
6
|
-
/**
|
|
7
|
-
* singleJSONParseHandler - to parse the json
|
|
8
|
-
* @param jsonString
|
|
9
|
-
* @param defaultValue
|
|
10
|
-
*/
|
|
11
|
-
export declare const singleJSONParseHandler: (jsonString: string, defaultValue: any) => any;
|
|
12
|
-
/**
|
|
13
|
-
* Function to generate a correlation ID for tracing
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export declare const generateCorrelationId: () => string;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export interface payLoadInterface {
|
|
2
|
-
statusCode?: number;
|
|
3
|
-
data?: any;
|
|
4
|
-
}
|
|
5
|
-
export interface LoggerInterface {
|
|
6
|
-
info(message: string, method: string): void;
|
|
7
|
-
warn(message: string, method: string, payload?: object): void;
|
|
8
|
-
error(message: string, method: string, payload?: object): void;
|
|
9
|
-
debug(message: string, method: string, payload?: object): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class LoggerClass implements LoggerInterface {
|
|
12
|
-
private logger;
|
|
13
|
-
private infoLevel;
|
|
14
|
-
private debugLevel;
|
|
15
|
-
private errorLevel;
|
|
16
|
-
private warnLevel;
|
|
17
|
-
private blockedKeywords;
|
|
18
|
-
constructor();
|
|
19
|
-
/**
|
|
20
|
-
* It's written to handle JSON.circular error
|
|
21
|
-
* @param obj
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
customstringify(obj: any): string;
|
|
25
|
-
/**
|
|
26
|
-
* for info log
|
|
27
|
-
* @param message
|
|
28
|
-
* @param payload
|
|
29
|
-
* @param method
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
info(message: string, method: string): void;
|
|
33
|
-
/**
|
|
34
|
-
* for warn log
|
|
35
|
-
* @param message
|
|
36
|
-
* @param payload
|
|
37
|
-
* @param method
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
warn(message: string, method: string, payload?: any): void;
|
|
41
|
-
/**
|
|
42
|
-
* for error log
|
|
43
|
-
* @param message
|
|
44
|
-
* @param payload
|
|
45
|
-
* @param method
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
error(message: string, method: string, payload?: any): void;
|
|
49
|
-
/**
|
|
50
|
-
* for debug log
|
|
51
|
-
* @param message
|
|
52
|
-
* @param payload
|
|
53
|
-
* @param method
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
debug(message: string, method: string, payload?: any): void;
|
|
57
|
-
/**
|
|
58
|
-
* to map log levels and handle from config
|
|
59
|
-
*/
|
|
60
|
-
private mapLogLevels;
|
|
61
|
-
/**
|
|
62
|
-
* to sanitize logs from unwanted fields to be shown
|
|
63
|
-
* @param request
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
private sanitizeLog;
|
|
67
|
-
}
|
|
68
|
-
export declare const Logger: LoggerClass;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
/**
|
|
3
|
-
* setTracers - to set the request tracers on the request
|
|
4
|
-
*/
|
|
5
|
-
export declare const setTracers: (req: Request, res: Response, next: NextFunction) => void;
|
|
6
|
-
export declare const getTraceId: () => any;
|
|
7
|
-
export declare const getSpanId: () => any;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
LOG_LEVELS: string[];
|
|
3
|
-
NODE_ENV: string;
|
|
4
|
-
APP_NAME: string;
|
|
5
|
-
RABBITMQ: {
|
|
6
|
-
USER: string;
|
|
7
|
-
PASS: string;
|
|
8
|
-
HOST: string;
|
|
9
|
-
PORT: string;
|
|
10
|
-
MAIN_QUEUE: string;
|
|
11
|
-
MAIN_EXCHANGE: string;
|
|
12
|
-
DLX_QUEUE: string;
|
|
13
|
-
DLX_EXCHANGE: string;
|
|
14
|
-
RETRY_QUEUE: string;
|
|
15
|
-
RETRY_EXCHANGE: string;
|
|
16
|
-
MAX_RETRIES: number;
|
|
17
|
-
HEARTBEAT: number;
|
|
18
|
-
TTL: string;
|
|
19
|
-
BACKOFF_TIME: number;
|
|
20
|
-
IS_ENABLED: string;
|
|
21
|
-
RABBITMQ_CONFIG: string;
|
|
22
|
-
PREFETCH_COUNT: number;
|
|
23
|
-
CONNECTION_ERROR: string | boolean;
|
|
24
|
-
PUBLISHER_ERROR: string | boolean;
|
|
25
|
-
CONSUMER_ERROR: string | boolean;
|
|
26
|
-
CONFIG_PATH: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export default _default;
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as amqp from 'amqplib';
|
|
2
|
-
import ConfigManager from '../config/ConfigManager';
|
|
3
|
-
import ConnectionManager from './ConnectionManager';
|
|
4
|
-
declare class BaseRabbitMQClient {
|
|
5
|
-
readonly configManager: ConfigManager;
|
|
6
|
-
readonly connectionManager: ConnectionManager;
|
|
7
|
-
protected connection: amqp.Connection | undefined;
|
|
8
|
-
protected channel: amqp.Channel | undefined;
|
|
9
|
-
protected configData: any;
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* Function for load the config data
|
|
13
|
-
*/
|
|
14
|
-
private init;
|
|
15
|
-
}
|
|
16
|
-
export default BaseRabbitMQClient;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import * as amqp from 'amqplib';
|
|
2
|
-
interface ConnectionWrapper {
|
|
3
|
-
connection: amqp.Connection;
|
|
4
|
-
channel: amqp.Channel;
|
|
5
|
-
}
|
|
6
|
-
declare class ConnectionManager {
|
|
7
|
-
private static instance;
|
|
8
|
-
private readonly configManager;
|
|
9
|
-
protected connection: amqp.Connection | undefined;
|
|
10
|
-
protected channel: amqp.Channel | undefined;
|
|
11
|
-
protected configData: any;
|
|
12
|
-
constructor();
|
|
13
|
-
/**
|
|
14
|
-
* Function for get channel
|
|
15
|
-
*/
|
|
16
|
-
getChannel(): amqp.Channel | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Function for get channel
|
|
19
|
-
*/
|
|
20
|
-
getConnection(): amqp.Connection | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Function for create and return intance
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
static getInstance(): Promise<ConnectionManager>;
|
|
26
|
-
/**
|
|
27
|
-
* Function to connect create to RabbitMQ
|
|
28
|
-
*/
|
|
29
|
-
createConnection(): Promise<ConnectionWrapper>;
|
|
30
|
-
/**
|
|
31
|
-
* Function for bind connection event handler on close and error setupQueuesAndExchanges
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
private bindConnectionEventHandler;
|
|
35
|
-
/**
|
|
36
|
-
* Function to check the status of the connection
|
|
37
|
-
* @returns boolean
|
|
38
|
-
*/
|
|
39
|
-
isConnected(): Promise<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Function to initialize the connection, channel and setup the queues and exchanges
|
|
42
|
-
* @param reqData
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
initialize(): Promise<{
|
|
46
|
-
connection: amqp.Connection | undefined;
|
|
47
|
-
channel: amqp.Channel | undefined;
|
|
48
|
-
} | undefined>;
|
|
49
|
-
/**
|
|
50
|
-
* Function to setup the queues and exchanges
|
|
51
|
-
* @params array
|
|
52
|
-
* @rtrun
|
|
53
|
-
*/
|
|
54
|
-
private setupQueuesAndExchanges;
|
|
55
|
-
/**
|
|
56
|
-
* Function for load the config data
|
|
57
|
-
*/
|
|
58
|
-
private init;
|
|
59
|
-
}
|
|
60
|
-
export default ConnectionManager;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IMessageBrokerClient } from './interface/IMessageBrokerClient';
|
|
2
|
-
import { PublishMessageInputType } from './types/PublishMessageInputType';
|
|
3
|
-
export declare class MessageBrokerClient implements IMessageBrokerClient {
|
|
4
|
-
private readonly rabbitMQClient;
|
|
5
|
-
private readonly messageProducer;
|
|
6
|
-
private readonly configManager;
|
|
7
|
-
private readonly isEnabledRabbitMQ;
|
|
8
|
-
private readonly configData;
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* Function to initialize the RabbitMQ connection
|
|
12
|
-
*/
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Function to close the connection and channel
|
|
16
|
-
*/
|
|
17
|
-
disconnect(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Function to publish a message with retry
|
|
20
|
-
* @param request
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
publishMessage(request: PublishMessageInputType): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Function to publish a message with retry to exchange
|
|
26
|
-
* @param request
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
publishMessageToExchange(request: PublishMessageInputType): Promise<boolean>;
|
|
30
|
-
/***
|
|
31
|
-
* Function to check if the connection is established
|
|
32
|
-
*/
|
|
33
|
-
isConnected(): Promise<boolean>;
|
|
34
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import BaseRabbitMQClient from "./BaseRabbitMQClient";
|
|
2
|
-
declare class MessageConsumer extends BaseRabbitMQClient {
|
|
3
|
-
private readonly messageProducer;
|
|
4
|
-
constructor();
|
|
5
|
-
/**
|
|
6
|
-
* Funvction for initialize consumer queue
|
|
7
|
-
* @param consumerQueues
|
|
8
|
-
*/
|
|
9
|
-
initializeConsumers(): Promise<{
|
|
10
|
-
error: string;
|
|
11
|
-
} | undefined>;
|
|
12
|
-
/**
|
|
13
|
-
* Function to consume message with retry
|
|
14
|
-
* @param queueName
|
|
15
|
-
*/
|
|
16
|
-
private consumerMessage;
|
|
17
|
-
/**
|
|
18
|
-
* Function for consumer massage handler
|
|
19
|
-
* @param channel
|
|
20
|
-
* @param queue
|
|
21
|
-
* @param message
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
private consumerHandler;
|
|
25
|
-
}
|
|
26
|
-
export default MessageConsumer;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import BaseRabbitMQClient from "./BaseRabbitMQClient";
|
|
2
|
-
import ConnectionManager from "./ConnectionManager";
|
|
3
|
-
import { PublishMessageInputType } from "./types/PublishMessageInputType";
|
|
4
|
-
declare class MessageProducer extends BaseRabbitMQClient {
|
|
5
|
-
private readonly correlationId;
|
|
6
|
-
connectionManager: ConnectionManager;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Function to publish a message with retry
|
|
10
|
-
* @param queueName
|
|
11
|
-
* @param message
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
publishMessage(request: PublishMessageInputType): Promise<boolean>;
|
|
15
|
-
/**
|
|
16
|
-
* Function to publish a message with retry
|
|
17
|
-
* @param exchangeName
|
|
18
|
-
* @param routingKey
|
|
19
|
-
* @param message
|
|
20
|
-
* @param options
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
publishMessageToExchange(request: PublishMessageInputType): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Funciton to message handler
|
|
26
|
-
*/
|
|
27
|
-
messageHandler(request: PublishMessageInputType): Promise<boolean>;
|
|
28
|
-
}
|
|
29
|
-
export default MessageProducer;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import BaseRabbitMQClient from './BaseRabbitMQClient';
|
|
2
|
-
export declare class RabbitMQClient extends BaseRabbitMQClient {
|
|
3
|
-
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* Function to initialize the RabbitMQ connection
|
|
6
|
-
*/
|
|
7
|
-
initialize(): Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* Function to close the connection and channel
|
|
10
|
-
*/
|
|
11
|
-
disconnect(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type ActionType<T> = (input: T) => void;
|
|
2
|
-
declare class RetryManager<T> {
|
|
3
|
-
private static instance;
|
|
4
|
-
private readonly max_retry;
|
|
5
|
-
private readonly retry_delay;
|
|
6
|
-
constructor(max_retry: number, retry_delay: string);
|
|
7
|
-
/**
|
|
8
|
-
* Function for create singlton class instance and return instance
|
|
9
|
-
* @param max_retry
|
|
10
|
-
* @param retry_delay
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
static getInstance<T>(max_retry: number, retry_delay: string): RetryManager<T>;
|
|
14
|
-
/**
|
|
15
|
-
* Function for perform action with retry
|
|
16
|
-
* @param actionHandler
|
|
17
|
-
* @param context
|
|
18
|
-
* @param failActionHandler
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
performActionWithRetry(actionHandler: ActionType<T>, context: T, failActionHandler: ActionType<T>): Promise<boolean>;
|
|
22
|
-
}
|
|
23
|
-
export default RetryManager;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PublishMessageInputType } from "../types/PublishMessageInputType";
|
|
2
|
-
export interface IMessageBrokerClient {
|
|
3
|
-
initialize(configData: object | null): void;
|
|
4
|
-
disconnect(): void;
|
|
5
|
-
publishMessage(request: PublishMessageInputType): Promise<boolean>;
|
|
6
|
-
publishMessageToExchange(request: PublishMessageInputType): Promise<boolean>;
|
|
7
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as amqp from 'amqplib';
|
|
2
|
-
import ConnectionWrapper from '../interface/ConnectionWrapper';
|
|
3
|
-
import { PublishMessageInputType } from '../types/PublishMessageInputType';
|
|
4
|
-
import { ActionType } from '../types/ActionType';
|
|
5
|
-
export declare class MessageBrokerClient {
|
|
6
|
-
/**
|
|
7
|
-
* Function to check the status of the connection
|
|
8
|
-
* @returns boolean
|
|
9
|
-
*/
|
|
10
|
-
isConnected(): Promise<boolean>;
|
|
11
|
-
/**
|
|
12
|
-
* Function to initialize the connection, channel and setup the queues and exchanges
|
|
13
|
-
* @param reqData
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
initialize(): Promise<{
|
|
17
|
-
connection: amqp.Connection;
|
|
18
|
-
channel: amqp.Channel;
|
|
19
|
-
} | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Function to publish a message with retry
|
|
22
|
-
* @param request
|
|
23
|
-
* @param classInstance
|
|
24
|
-
* @param messagePublisherErrorHandler
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
publishMessage(request: PublishMessageInputType): Promise<true | undefined>;
|
|
28
|
-
/**
|
|
29
|
-
* Function to publish a message with retry
|
|
30
|
-
* @param request
|
|
31
|
-
* @param classInstance
|
|
32
|
-
* @param messagePublisherErrorHandler
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
publishMessageToExchange(request: PublishMessageInputType): Promise<boolean>;
|
|
36
|
-
/**
|
|
37
|
-
* Funciton to message handler
|
|
38
|
-
*/
|
|
39
|
-
messagePublisherErrorHandler(request: PublishMessageInputType): Promise<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Funvction for initialize consumer queue
|
|
42
|
-
* @param consumerQueues
|
|
43
|
-
*/
|
|
44
|
-
initializeConsumers(classInstance: any, consumerHandler: string, consumerErrorHandler: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Function for perform action with retry
|
|
47
|
-
* @param actionHandler
|
|
48
|
-
* @param context
|
|
49
|
-
* @param failActionHandler
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
performActionWithRetry<T>(actionHandler: ActionType<T>, failActionHandler: ActionType<T>, context: T): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Function to consume message with retry
|
|
55
|
-
* @param queueName
|
|
56
|
-
*/
|
|
57
|
-
consumeMessage(queueName: string, classInstance: any, consumerHandler: string, consumerErrorHandler: string): Promise<amqp.Replies.Consume | undefined>;
|
|
58
|
-
/**
|
|
59
|
-
* Function to send message to dead later queue
|
|
60
|
-
* @param attempt
|
|
61
|
-
* @param data
|
|
62
|
-
* @param queueName
|
|
63
|
-
* @retruns
|
|
64
|
-
*/
|
|
65
|
-
sendMessageToDeadLatter(attempt: number, data: any): Promise<boolean>;
|
|
66
|
-
/***
|
|
67
|
-
* Function to send message to retry queue
|
|
68
|
-
* @param attempt
|
|
69
|
-
* @param data
|
|
70
|
-
* @param retryDelay
|
|
71
|
-
* @param queueName
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
sendMessageToRetryQueue(attempt: number, data: any, retryDelay: any, queueName: string): Promise<boolean | undefined>;
|
|
75
|
-
/**
|
|
76
|
-
* Function to find the queue, exchange and add binding
|
|
77
|
-
* @param queueName
|
|
78
|
-
* @param exchangeName
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
findQueueAndExchange(queueName: string, exchangeName: string): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* Function to check connection and channel
|
|
84
|
-
*/
|
|
85
|
-
private checkConnectionAndChannel;
|
|
86
|
-
/**
|
|
87
|
-
* Function to recreate channel
|
|
88
|
-
*/
|
|
89
|
-
private recreateChannel;
|
|
90
|
-
/**
|
|
91
|
-
* Function to setup the queues and exchanges
|
|
92
|
-
* @params array
|
|
93
|
-
* @rtrun
|
|
94
|
-
*/
|
|
95
|
-
private setupQueuesAndExchanges;
|
|
96
|
-
/**
|
|
97
|
-
* Function to binding queue and exchange
|
|
98
|
-
* @param exchangeName
|
|
99
|
-
* @param queueName
|
|
100
|
-
* @param routingKey
|
|
101
|
-
*/
|
|
102
|
-
private bindQueueAndExchanges;
|
|
103
|
-
/**
|
|
104
|
-
* Function to create the queue
|
|
105
|
-
* @param data
|
|
106
|
-
*/
|
|
107
|
-
private createQueue;
|
|
108
|
-
/**
|
|
109
|
-
* Function to create the exchange
|
|
110
|
-
* @param data
|
|
111
|
-
*/
|
|
112
|
-
private createExchange;
|
|
113
|
-
/**
|
|
114
|
-
* Function to connect create to RabbitMQ
|
|
115
|
-
*/
|
|
116
|
-
createConnection(): Promise<ConnectionWrapper>;
|
|
117
|
-
/**
|
|
118
|
-
* Function for bind connection event handler on close and error setupQueuesAndExchanges
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
private bindConnectionEventHandler;
|
|
122
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ActionType<T> = (input: T) => void;
|
/package/{dist/src/models/NotificationMessageModel.d.ts → src/models/NotificationMessageModel.ts}
RENAMED
|
File without changes
|