Use NCache for Pub/Sub Messaging in Node.js
Before getting started with NCache in Node.js, take the following prerequisites under consideration:
- Node.js version 14.15.3 or above is installed with Chocolatey.
- JDK 9 is installed.
- Environment Variable for Java is set.
Pub/Sub Demonstration of Pub/Sub
Follow the steps mention below to see how NCache acts as a communication medium for a Publisher/Subscribe model in Node.js.
Step 1: Download Sample From GitHub
Go to NCache repository on GitHub to download the repo containing Pub/Sub sample.
Step 2: Launch the Project
Launch the Pub/Sub sample application in Visual Studio Code or any IDE of your preference.
Step 3: Configure Settings
In the app-config.json file, replace the
cacheName attribute with the cache that you created in the previous step. Save the file.
Step 4: Build the Project
Once you have configured the application with your custom cache, build the project.
Step 5: Monitor Cache Stats
To verify that NCache acts as a message broker for the sample publisher/subscriber application, NCache provides various stats counters that let you view the state of your cache. Go to Monitor Pub/Sub Topic Statistics to understand what these counters are and how to monitor them.