@actionlogementservices/wdio-test-context 1.1.0 → 1.1.1
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/package.json +1 -1
- package/src/amqp-client.js +14 -7
package/package.json
CHANGED
package/src/amqp-client.js
CHANGED
|
@@ -27,7 +27,7 @@ export async function publishMessage(connectionString, exchange, routingKey, typ
|
|
|
27
27
|
let channel;
|
|
28
28
|
try {
|
|
29
29
|
connection = await amqp.connect(connectionString, { clientProperties: { connection_name: appId } });
|
|
30
|
-
channel = await connection.
|
|
30
|
+
channel = await connection.createConfirmChannel();
|
|
31
31
|
const content = Buffer.from(JSON.stringify(payload));
|
|
32
32
|
/** @type {import('amqplib').Options.Publish} */ const options = {
|
|
33
33
|
appId,
|
|
@@ -36,14 +36,21 @@ export async function publishMessage(connectionString, exchange, routingKey, typ
|
|
|
36
36
|
timestamp: Date.now(),
|
|
37
37
|
type
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return new Promise((resolve, reject) =>
|
|
40
|
+
channel.publish(exchange, routingKey, content, options, error => {
|
|
41
|
+
if (error) {
|
|
42
|
+
logger.detailError(error);
|
|
43
|
+
reject(`Amqp error: '${error.message}'!`);
|
|
44
|
+
} else {
|
|
45
|
+
logger.debug('Amqp message sent.');
|
|
46
|
+
resolve(true);
|
|
47
|
+
}
|
|
48
|
+
if (channel) channel.close();
|
|
49
|
+
if (connection) connection.close();
|
|
50
|
+
})
|
|
51
|
+
);
|
|
42
52
|
} catch (error) {
|
|
43
53
|
logger.detailError(error);
|
|
44
54
|
throw new Error(`Amqp error: '${error.message}'!`);
|
|
45
|
-
} finally {
|
|
46
|
-
if (channel) channel.close();
|
|
47
|
-
if (connection) connection.close();
|
|
48
55
|
}
|
|
49
56
|
}
|