wrappers/tests/testBroker.js

25 lines
654 B
JavaScript
Raw Normal View History

import { readFileSync } from 'fs';
2023-07-03 15:33:39 +02:00
import { MessageBroker } from '../build/esm/index.js';
const credentials = JSON.parse(readFileSync('../brokerCreds.json', { encoding: 'utf-8' }));
2023-07-03 15:33:39 +02:00
const broker = new MessageBroker({
createLogger: () =>
{
return {
debug: console.log,
info: console.log,
status: console.log,
warn: console.log,
error: console.error
};
}
}, credentials);
2023-07-03 15:33:39 +02:00
await broker.init();
broker.subscribe('db_cluster_status', (message) =>
2023-07-03 15:33:39 +02:00
{
if (message instanceof Buffer)
console.log(message.toString());
else
console.log(message);
2023-07-03 15:33:39 +02:00
});