aux-broker-mq
Version:
Микросервис тест взаимодействия
29 lines (24 loc) • 893 B
JavaScript
const { BrokerProxy } = require("../dist/BrokerProxy");
const broker = new BrokerProxy({ host: "auxilium:Saq33rrT@localhost" });
(async () => {
try {
await broker.connect();
await broker.createChannel("testService.health");
await broker.createExchange("article", "fanout");
await broker.createExchange("reviews", "direct");
const article = await broker.bind("article",'');
const reviews = await broker.bind("reviews",'fake.cinema.cols');
article.subscribe((msg) => {
console.log("Exchange:",msg, Date.now());
})
reviews.subscribe((msg) => {
console.log("reviews:",msg, Date.now());
})
broker.on("testService.health").subscribe((msg) => {
console.log("testService.health", Date.now() - msg.date, msg);
});
console.log("[*] Доступно подключение");
} catch (ex) {
console.log(ex);
}
})();