This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1844|Reply: 1

[Console Program] .NET/C# console services are registered with Consul service discovery

[Copy link]
Posted on 12/20/2024 2:46:54 PM | | | |
Requirements: Using the .NET 8 controller, some background services are developed that support cluster deployment, can be deployed to multiple servers, and process tasks in parallel.

Review:

Consul installation tutorial in a Windows test environment
https://www.itsvse.com/thread-10613-1-1.html

.NET/C# checks if a TCP port is available
https://www.itsvse.com/thread-10721-1-1.html

Consul Health Check supports protocols or methods: Script, HTTP, TCP, UDP, Time-to-live (TTL), Docker, gRPC, H2ping, and Alias.

Link:

The hyperlink login is visible.
The hyperlink login is visible.

You can register the console service with Consul, and the application uses TcpListener to listen on a TCP port, and Consul checks the health status of the console service based on TCP. As shown below:



The order of services needs to be taken into account in the project, and semaphores need to be used.The program registers to consul and must wait for TCP to listen to the port successfully!!!

Start multiple consoles, as shown below:



The code is as follows:



The project code is as follows:


(End)




Previous:Perform a diagnostic test on memory with Memtest86 Pro v11
Next:Angular 18 Series (Twenty-Eight) InjectionToken Brief Introduction
 Landlord| Posted on 12/23/2024 11:38:18 AM |
The technology used by the code


The difference between ManualResetEvent and AutoResetEvent learned by C# threads
https://www.itsvse.com/thread-4810-1-1.html


Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com