- Install docker from here if you don't already have it.
- Install .NET SDK 9.0 from here Make sure to download the correct version as per your OS and architecture. Make sure to download dotnet 9 not 10.
docker pull nats:latest
docker run -p 4222:4222 -ti nats:latest --jetstreamThe NATS CLI is useful for local debugging and managing your NATS server. While the CLI automatically connects to nats://127.0.0.1:4222 by default, setting up a context is recommended for clarity.
brew tap nats-io/nats-tools
brew install nats-io/nats-tools/natsOption 1: Using Scoop (if you have Scoop installed)
scoop bucket add extras
scoop install extras/natscliOption 2: Manual Installation
- Download the latest NATS CLI release from the official NATS CLI releases page
- Extract the
nats-<version>-windows-amd64.zipfile - Add the directory containing
nats.exeto your system PATH:- Press
Win + R, typesysdm.cpl, and press Enter - Go to the "Advanced" tab and click "Environment Variables"
- Under "System variables," select "Path" and click "Edit"
- Click "New" and add the path to the directory containing
nats.exe - Click "OK" to save changes
- Press
- Verify installation by opening a new command prompt and running:
nats --version
After installing the NATS CLI, you can create a context pointing to your local NATS instance:
# Create a context named 'local' pointing to the local NATS server
nats context save local --server=nats://127.0.0.1:4222
# Set 'local' as the default context
nats context select localNote: The NATS CLI will automatically connect to
nats://127.0.0.1:4222by default, so setting up a context is optional. However, it's useful for managing multiple environments or when you need to switch between different NATS servers.
Easiest way to start with cloops.microservices especially if you are outside Connection Loops. Bootstrap from our GitHub Template
This is the recommended way to setup a new project within Connection Loops as we do not use GitHub for our private repos.
# install the template (If you do not have it)
dotnet new install cloops.microservice.template
# If you have the template, but want to make sure you get the latest one
dotnet new uninstall cloops.microservice.template
# Create a new project
dotnet new cloops.microservice -n <name_of_service>Add cloops.nats package reference to your .csproj file. Please note we deliberately want all of our consumers to stay on latest version of the SDK.
<PackageReference Include="cloops.microservices" Version="*" />Once added, just to dotnet restore to pull in the SDK.
Usage (Program.cs) -
using CLOOPS.microservices;
var app = new App();
await app.RunAsync();You can provide a custom function to generate a personalized intro message when the application starts. The function receives BaseAppSettings and the non-null WebApplicationBuilder as parameters and should return a string.
using CLOOPS.microservices;
var app = new App((settings, builder) =>
{
return $@"
╔══════════════════════════════════════╗
║ My Custom Application Banner ║
╚══════════════════════════════════════╝
Application: {settings.AssemblyName}
Environment: {builder.Environment.EnvironmentName}
Cluster: {settings.Cluster}
NATS: {settings.NatsURL}
";
});
await app.RunAsync();If no custom function is provided, the default CLOOPS banner will be displayed.
If you would like to know more about services. Please read services