If you need to send real time messages between the servers in a multi server setup you can use Redis Pub/Sub to accomplish this.
This module is disabled by default but can be configured via config.
{
"redis": {
"enabled": false,
"host": "127.0.0.1",
"port": 6379,
"scope": "dpdk_npm_next_bootstrap"
}
}
const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);
bootstrap.init();
// Returns: true/false based on the fact if the message was received by the server
// Params: channel, message
const messageStatus = bootstrap.redis.client.publish('example', {
message: 'Hello World'
});
const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);
bootstrap.init();
// Returns: the unsubscribe function along the current subscribed channel
// Params: channel, callback
const exampleChannel = bootstrap.redis.client.subscribe('example', (data) => {
console.log(data);
});
Additional Redis Pub/Sub Library Documentation: https://www.npmjs.com/package/node-redis-pubsub
Additional Redis Pub/Sub Documentation: https://redis.io/topics/pubsub
Last modified | Friday, April 30, 2021, 12:00:21 PM UTC |
Last author | Colin van Eenige |
Commit ID | 4c7a701 |