net core micro-services framework for rapid development

dymDemo 

github Address: https://github.com/duyanming/dymDemo

dym 分布式开发框架 Demo 熔断 限流 事件总线(包括基于内存的、rabbitmq的) CQRS DDD 实例 随后更新

dym distributed development framework

dym 是一个分布式开发框架,同时支持 .net core2.2 、.net frameworker4.6.1。

1. Run Demo

第一步:启动注册中心
    进入项目文件夹 dymDemo\YY.AppCenter\bin\Debug\netcoreapp2.2 ,运行命令 dotnet AppCenter.dll
    看到下图 说明运行成功
代码:默认监听6660端口
 using dym.Rpc.Center;
    static class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "YY.AppCenter";
            Bootstrap.StartUp(args);
        } 

    }

Profile: dym.config

After the service starts registered to the <Servers> node within

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--#lbs 配置-->
  <Port>6660</Port>
  <TimeOut>120000</TimeOut>
  <Servers>
 
  </Servers>
</configuration>

 

first step

第二步:启动服务Server  
    Server可以和 AppCenter 不在同一台电脑,也可以运行多个server 也可以负载均衡,高级用法随后介绍
    进入项目文件夹 dymDemo\YY.Server\bin\Debug\netcoreapp2.2 ,运行命令 dotnet YY.Server.dll
    看到下图 说明 Server 成功运行 并且已经注册到 注册中心(APPCenter)运行成功
代码:默认监听6659端口
 using dym.Rpc.Server;
    static class Program
    {
        static void Main(string[] args)
        {
            Bootstrap.StartUp(args);
        }

    }

Profiles:

<? XML Version = "1.0" encoding = "UTF-. 8" ?> 
< Configuration > 
  <-! 0,0 is the first station, the second data center 
  (all APPservice digit can not be repeated, for example, can not be the presence of [1,2] [1,2]) 
  may be present [1,2] [2,1] 
  -> 
  < IdWorker > 0,0 </ IdWorker > 
  <-! the App name -> 
  < AppName > App001 </ AppName > 
  <-! listen port -> 
  < port > 6659 </ port > 
  <-! weight -> 
  <Weight>1</Weight > 
  <-! Feature non dym.Plugs way to join -> 
  < FuncName > </ FuncName > 
  <-! Ignore function Trace, Logic -> 
  < IgnoreFuncName > </ IgnoreFuncName > 
  <-! Timeout milliseconds -> 
  < TimeOut > 20000 </ TimeOut > 
  <-! registered to the target -> 
  < Ts Ip = "10.112.93.122" Port = "6660" /> 
  < IocDll > 
    <-! IOC storage -> <!--
    <Assembly>dym.Repository</Assembly>
    --><!-- 领域--><!--
    <Assembly>dym.Domain</Assembly>
    --><!-- 查询服务--><!--
    <Assembly>dym.QueryServices</Assembly>
    --><!--事件Handler--><!--
    <Assembly>dym.Command.Handler</Assembly>-->
  </IocDll>

</configuration>
业务代码示例:dym.Plugs.YYTestService
Service launch configuration
a using System;
 a using dym.EngineData; 

namespace dym.Plugs.YYTestService 
{ 
    // service startup configuration 
    public  class YYTestBootstrap: IPlugsConfigurationBootstrap 
    { 
        public  void ConfigurationBootstrap () 
        { 
            / * 
             * service will start when performing this method 
             * can also be used to load plug-ins configuration 
             * / 

        } 

        public  void PreConfigurationBootstrap () 
        { 
            // before injection Ioc 
        } 
    } 
}

Business writing:

using dym.EngineData;
using System;
using System.Collections.Generic;
using System.Text;

namespace dym.Plugs.YYTestService
{
    public class MyFirstModule: BaseModule
    {
        public MyFirstModule() {
        }

        public ActionResult MyT() {
            var xx = RequestString("XX");
            Console.WriteLine($"来自客户端的消息:{xx}");
            return new ActionResult(true,new { Msg= " I from dym.Plugs.YYTestService MyFirstModule!" },null, xx);
        }
    }
}

 

 

The second step

第三步:启动Client测试分布式框架是否可以正常运行
    启动Client 测试 Client调用 Server是否成功
    进入项目文件夹 dymDemo\YY.Client\bin\Debug\netcoreapp2.2 ,运行命令 dotnet YY.Client.dll
    看到下图 说明 Client 成功运行 

客户端代码:
the using the System; 

the using dym.Rpc.Client; 

namespace YY.Client 
{ 
    class Program 
    { 
        static  void the Main ( String [] args) 
        { 
            / * 
             *. 1, AppName 
             * 2, registry 
             * 3, the registry port 
             * 4, close call chain track 
             * / 
            DefaultConfigManager.SetDefaultConfiguration ( " YY.Client " , " 127.0.0.1 " , 6660 , false ); 
            the Restart: 
            Console.WriteLine ( "Please enter a carriage return message is then sent to the server: " );
             var InputMsg = Console.ReadLine ();
             var INPUT = new new InputTest () 
            { 
                Channel = " dym.Plugs.YYTest " , 
                Router = " MyFirst " , 
                Method = " MYT " , 
                XX = $ " {} InputMsg parameters. 1 " 
            }; 

            var rltStr = Connector.BrokerDns (INPUT);
             //var outPut = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(rltStr);
            Console.WriteLine(rltStr);

            Console.WriteLine("-----------------------------------------------------------------------------");

            var inputYYTest = new InputTest()
            {
                channel = "dym.Plugs.YYTest",
                router = "MySecond",
                method = "MyT",
                XX = $"{inputMsg}参数2"
            };
            var rltStrYY = Connector.BrokerDns(inputYYTest);
            //var outPutYY = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(rltStr);
            Console.WriteLine(rltStrYY);
            goto Restart;
        }
    }

    public class InputTest : InputDtoBase
    {
        public string XX { get; set; }
    }
}

 

 

third step

Guess you like

Origin www.cnblogs.com/duyanming/p/10998081.html