SmartRoute


服务即集群

智能集成服务通讯交互

不需要具备通讯专业知识即可轻松构建

零配置、零安装引用组件即可用

可快速构建服务应用通讯,消息分发,网关集群和集群负载应用

应用场景


下载
帮助

smartroute-0.7





简单应用代码


消息订阅


class Program
{
    static SubscribeEvent henry;
    static void Main(string[] args)
    {
        Route.AddLogHandler(new ConsoleLogHandler(LogType.DEBUG | 
            LogType.ERROR | LogType.FATAL | LogType.INFO | 
            LogType.NONE | LogType.WARN));
        Route.DefaultNode.Open();
        henry = new SubscribeEvent("henry");
        henry.RegisterProcess<Hello>((o, e) =>
        {
            Console.WriteLine(e.Message.GetBody<Hello>().Content);
            e.Result = e.Message.Reply(new Hello { Content = "I'm fine!" });
        });
        System.Threading.Thread.Sleep(-1);
    }
}



消息投递


class Program
{
    static SubscribeEvent ken;
    static void Main(string[] args)
    {
        Route.AddLogHandler(new ConsoleLogHandler(LogType.DEBUG |
            LogType.ERROR | LogType.FATAL | LogType.INFO |
            LogType.NONE | LogType.WARN));
        Route.DefaultNode.Open();
        ken = new SubscribeEvent("ken");
        while (true)
        {
            Hello hello = new Hello { Content = "hello henry! how are you?" };
            IMessage message = ken.Send("henry", hello);
            if (message != null)
                Console.WriteLine(message.GetBody<Hello>().Content);
            System.Threading.Thread.Sleep(1000);
        }
    }
}