Closed willin closed 6 years ago
How do you do this insertion? the published event should happen only in the originating server.
const messageHandler = async (topic, payload) => {
const decodedMessage = Message.decode(payload);
await mysqlInsert(decodedMessage);
};
server.subscribe('device/+/pubmessage', messageHandler);
You should use the published event then, not subscribing. That is equivalent to a client subscription.
server.on('published', (packet, client) => {
});
do you mean this?
we tried this before, but it receives too many unuseful sys messages.
That’s what you should use. You can filter using mqemitter if you need to.
oic
i have several servers
their config file are the same, all connect to a same redis server:
and what the mosca server do is receive messages and insert them to mysql server.
the situation now is: when a message was sent to a specific/single server, all servers get the message and then this message was inserted duplicate times.