Based on the. NET Core MicroServices Framework-an analysis of how to use surging

Source: Internet
Author: User
Tags rabbitmq

1 , preface

Surging by everyone so much attention, I am very surprised, such as a colleague in the company sharing the surging, as well as in the blog with other RPC framework, micro-service to do the comparison, and so on, these actions have made me feel very stressed, after all, as a personal open-source project, It is not possible to compare with the mature open source community projects, but also wait until there are many like-minded friends to join together to develop and perfect surging, so as to make surging a popular micro-service framework.

This article describes how to use the surging

Open Source Address: https://github.com/dotnetcore/surging

2 , Design Patterns

The surging offers the following four design modes

2.1 Proxy Mode

Different microservices are called by proxy. and the needle controls its access for the rule, as shown in:

2.2 Asynchronous Message Pattern

The MicroServices-based architecture chooses to use Message Queuing instead of the request/response pattern when dealing with waiting and blocking issues, as shown in:

2.3 Chain Mode

This mode responds to each other when the request is received, as shown in the following:

Service a receives the request and communicates with service B, and Service B communicates with service C. Communication between all services uses Netty-based RPC traffic.

2.4 Branch Mode

This mode allows multiple service providers to be called to merge data for return, as shown in:

3 , external how to interact

Services are processed primarily for submitted data, and are processed in the form of unified access to a single service or multiple service calls, as shown in

The gateway includes the following features:

    1. Secure Identity authentication
    2. Unified Access
    3. Flow control
    4. Shunt control
    5. Data monitoring
    6. Cache blocking
2. Simple Example Server
var host = new Servicehostbuilder (). Registerservices (option=> {option. Initialize (); Initializes the service option. Registerservices ();//Dependency Injection domain service option. Registerrepositories ();//Dependency Injection warehousing option. Registermodules ();//dependency inject third-party module option. Registerservicebus ();//Dependency Injection Servicebus}). Registerservices (builder = {Builder. Addmicroservice (option = {option. Addserviceruntime ();///option. Usezookeepermanager (New Configinfo ("127.0.0.1:2181")); Use Zookeeper to manage option. Useconsulmanager (New Configinfo ("127.0.0.1:8500"));//Use Consul to manage option. Usedotnettytransport ();//Use Netty to transfer option. Userabbitmqtransport ();//Use RABBITMQ to transfer option. ADDRABBITMQADAPT ()///RABBITMQ-based consumption service is adaptable to builder. Register(p = new Cplatformcontainer (servicelocator.current));//Initialize injection container}); })               . Subscribeat ()//message subscription. Useserver ("127.0.0.1", 98)//. Useserver ("127.0.0.1", 98, "true")//Automatically generate tokens//. Useserver ("127.0.0.1", 98, "123456789")//fixed password token. Usestartup<startup> ().                          Build (); using (host. Run ()) {Console.WriteLine ($ "Server started successfully, {DateTime.Now}.           "); }

Service Routing Access configuration

On the interface, add the following attribute (the Uniform method configuration is not yet implemented)

   [Servicebundle ("api/{service}")]
Service creation proxy call (requires interface creation proxy)
Servicelocator.getservice<iserviceproxyfactory> (). Createproxy<t> (Key)
The service is called according to Routepath (no dependency interface, low coupling)
Servicelocator.getservice<iserviceproxyprovider> (). Invoke<string> (model, PATH, Servicekey)
Local module and service invocation
Servicelocator.getservice<t> (Key)

Through the above configuration, can be accessed through the gateway, if we want to access the interface Iuserservice, the method is GetUser, the rules of the route map [Servicebundle ("api/{service}/{method }"), the converted address should be api/user/getuser,

The effect of using the Postman test is as follows:

4. Summary

Surging external through the API Gateway Rest Access, internal through the Netty RPC access, surging is still constantly improving, help documents are also in the rush, please wait patiently. If interested please pay more attention or join QQ Group: 615562965

Based on the. NET Core MicroServices Framework-an analysis of how to use surging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.