sb-rabbitmq-provider 1.0.19 → 1.0.23
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/dist/index.d.ts +5 -4
- package/dist/index.js +4 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -15,7 +15,6 @@ interface rabbitMQConfig {
|
|
15
15
|
vhost?: string | undefined;
|
16
16
|
exchangeName?: string;
|
17
17
|
exchangeType: string;
|
18
|
-
publishOptions?: Record<string, string> | undefined;
|
19
18
|
}
|
20
19
|
type MyCallback = (data: any) => any;
|
21
20
|
declare class RabbitMqConnection {
|
@@ -23,7 +22,6 @@ declare class RabbitMqConnection {
|
|
23
22
|
exchange: string;
|
24
23
|
exchangeType: string;
|
25
24
|
connection: any;
|
26
|
-
publishOptions: Options.Publish | undefined;
|
27
25
|
/**
|
28
26
|
* constructor for initialising url, exchange name, exchange type
|
29
27
|
* @param url rabbitmq url
|
@@ -49,7 +47,7 @@ declare class RabbitMqConnection {
|
|
49
47
|
* @param message object
|
50
48
|
* @returns
|
51
49
|
*/
|
52
|
-
publish(channel: RabbitMQChannel, queueName: string, message: object): Promise<{
|
50
|
+
publish(channel: RabbitMQChannel, queueName: string, message: object, publishOptions?: undefined): Promise<{
|
53
51
|
status: boolean;
|
54
52
|
message: string;
|
55
53
|
}>;
|
@@ -62,7 +60,10 @@ declare class RabbitMqConnection {
|
|
62
60
|
* @param callback function for handling the data
|
63
61
|
* @returns
|
64
62
|
*/
|
65
|
-
consume(channel: RabbitMQChannel, queueName: string, onMessage: MyCallback, options: Options.Consume
|
63
|
+
consume(channel: RabbitMQChannel, queueName: string, onMessage: MyCallback, options: Options.Consume, queueOptions?: {
|
64
|
+
durable: boolean;
|
65
|
+
autoDelete: boolean;
|
66
|
+
}): Promise<{
|
66
67
|
status: boolean;
|
67
68
|
message: string;
|
68
69
|
}>;
|
package/dist/index.js
CHANGED
@@ -33,7 +33,6 @@ class RabbitMqConnection {
|
|
33
33
|
if (config.exchangeType && typeof config.exchangeType === 'string') {
|
34
34
|
this.exchangeType = config.exchangeType;
|
35
35
|
}
|
36
|
-
this.publishOptions = config.publishOptions || undefined;
|
37
36
|
this.config = config;
|
38
37
|
}
|
39
38
|
/**
|
@@ -77,11 +76,11 @@ class RabbitMqConnection {
|
|
77
76
|
* @param message object
|
78
77
|
* @returns
|
79
78
|
*/
|
80
|
-
publish(channel, queueName, message) {
|
79
|
+
publish(channel, queueName, message, publishOptions = undefined) {
|
81
80
|
return __awaiter(this, void 0, void 0, function* () {
|
82
81
|
try {
|
83
82
|
const bufferMessage = Buffer.from(JSON.stringify(message));
|
84
|
-
channel.publish(this.exchange, queueName, bufferMessage,
|
83
|
+
channel.publish(this.exchange, queueName, bufferMessage, publishOptions);
|
85
84
|
return { status: true, message: 'Data sent to Queue' };
|
86
85
|
}
|
87
86
|
catch (error) {
|
@@ -98,10 +97,10 @@ class RabbitMqConnection {
|
|
98
97
|
* @param callback function for handling the data
|
99
98
|
* @returns
|
100
99
|
*/
|
101
|
-
consume(channel, queueName, onMessage, options) {
|
100
|
+
consume(channel, queueName, onMessage, options, queueOptions = { durable: true, autoDelete: false }) {
|
102
101
|
return __awaiter(this, void 0, void 0, function* () {
|
103
102
|
try {
|
104
|
-
const { queue } = yield channel.assertQueue(queueName,
|
103
|
+
const { queue } = yield channel.assertQueue(queueName, queueOptions);
|
105
104
|
yield channel.bindQueue(queue, this.exchange, queueName);
|
106
105
|
channel.consume(queueName, (message) => {
|
107
106
|
// channel.ack(message);
|