zoukankan      html  css  js  c++  java
  • 初步理解NServiceBus

    概述

    NServiceBus 是一个用于构建企业级 .NET系统的开源通讯框架。它在消息发布/订阅支持、工作流集成和高度可扩展性等方面表现优异,因此是很多分布式系统基础平台的理想选择。,它能够帮助开发人员在搭建企业.NET系统时避免很多典型的常见问题。同时,该框架也提供了一些可伸缩的关键特征,比如对发布/订阅的支持、集成的长时间工作流及深入的扩展能力等。据作者说,其本意是为构建分布式应用软件创建一个理想的基础设施。

    NServiceBus的核心并不依赖于MSMQ。NServiceBus可扩展性允许我们插入自行编写的通信传送器,、订阅存储器和工作流的实现。我已经基于MSMQ实现了一个传送器,还有一个则借助了WCF的NetTCP。开发人员既可以使用这些现有组件,也可以根据需要进行自定义。我们知道当前的许多SOA产品都与HTTP紧密耦合,因此NServiceBus的这种实现方式也将是个另辟蹊径的设计。
    之所以选择使用MSMQ,是因为它是微软公司的两大主流的通讯技术之一(另一个是SQL Server Service Broker)。MSMQ允许双方在离线的状态下进行通信,且它提供了一整套易于使用的API,并已经集成到了.NET框架中,这一点要比Service Broker好得多。我个人认为支持离线通信是任何SOA基础框架都必须考虑的关键部分——因为Tenet of Service Autonomy 并不能保证当前通信的另一端处于可用状态。

    NServiceBus是dotnet世界里面最流行的开源企业服务总线.  它具有以下特点: 1.强大,轻量级.     2.可插拨,简单易用.     3.支持企业级开发.

    在internet中的应用

    image

    Publish / Subscribe (发布者/订阅者)

    ²这种方式解决了发布消息对象知道消息发送给谁.(谁订阅了就给谁发)

    Subscriptions (订阅者)

    image

    Publish(发布者)

    image

    NserviceBus in Distributor(在分布式系统的应用)

    One publish(一个发布者):

    image

    Two publish(两个发布者的时候):

    image

    Point to Point(点对点通信)

    image

    Point to Point Configuration(需要配置)

    Client
    
    class EndPointConfig : IConfigureThisEndpoint, AsA_Client { } 
    
    <UnicastBusConfig>      <MessageEndpointMappings>       <add Messages="MyMessages“ Endpoint="MyServerInputQueue" />   </MessageEndpointMappings> 
    </UnicastBusConfig>
    Server
    
    class EndPointConfig : IConfigureThisEndpoint, AsA_Server { } 
    
    <MsmqTransportConfig InputQueue="MyServerInputQueue" />

    Request & Response(请求\回复)

    image

    Publish & Subscribe(发布者\订阅者)

    image

    Subscriber
    
    class EndPointConfig : IConfigureThisEndpoint, AsA_Server { } 
    
    <MsmqTransportConfig InputQueue=Subscriber1InputQueue" />   <UnicastBusConfig>      <MessageEndpointMappings>       <add Messages="MyMessages" Endpoint=" MyPublisherInputQueue" />     </MessageEndpointMappings>   </UnicastBusConfig>
    Publisher
    
    class EndPointConfig : IConfigureThisEndpoint, AsA_Publisher { } 
    
    <MsmqTransportConfig InputQueue="MyPublisherInputQueue />

    Saga(Workflow)

    image

    Server
    
    class EndPointConfig : IConfigureThisEndpoint, AsA_Server { } 
    
    <MsmqTransportConfig InputQueue=MySagaInputQueue" /> 
      <UnicastBusConfig>   <MessageEndpointMappings>     <add Messages="MyMessages" Endpoint="MyDestinationInputQueue" /> 
          <add Messages=“NServiceBus.Saga.TimeoutMessage” Endpoint=“timeoutmanager” >   </MessageEndpointMappings> 
      </UnicastBusConfig>
    
    <NHibernateSagaPersisterConfig>
      <NHibernateProperties>
          <add Key="connection.provider“ Value="NHibernate.Connection.DriverConnectionProvider"/>
          <add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver"/>
          <add Key="connection.connection_string" Value="Server=localhost;initial 	catalog=NServiceBus;Integrated Security=SSPI"/>
          <add Key="dialect" Value="NHibernate.Dialect.MsSql2000Dialect"/>
        </NHibernateProperties>
      </NHibernateSagaPersisterConfig>

    Distributor(分布式系统)

    image

    <appSettings>   <add key="NumberOfWorkerThreads" value="1"/>   <!-- queue that the distributor process reads and feeds to workers -->   <add key="DataInputQueue" value="nservicebus_distributor_data_bus"/> 
      <!--queue that manages work distribution -->  <add key="ControlInputQueue“ 	value="nservicebus_distributor_control_bus"/>   <!-- errors -->   <add key="ErrorQueue" value="nservicebus_error"/>   <!-- queue that maintains the state(availability) of the workers -->   <add key="StorageQueue" value="nservicebus_distributor_storage"/>      <!-- relevant for a Serialization of "interfaces" or "xml" -->   <add key="NameSpace" value="http://www.MySite.com"/>         <add key="Serialization" value="xml"/>   <!-- can be either "xml", or "binary" --> 
    </appSettings> 

    欢迎各位参与讨论,如果觉得对你有帮助,请点击image    推荐下,万分谢谢.

    作者:spring yang

    出处:http://www.cnblogs.com/springyangwc/

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    python数字图像处理(一)图像的常见操作
    python数字图像处理(二)关键镜头检测
    使用python开启你的opencv之旅---图像的读入,存储
    Opencv3.3(Linux)编译安装至python的坑
    PNG文件格式
    从Flask-Script迁移到Flask-Cli
    typing-python用于类型注解的库
    正方教务处抓包分析
    scala worksheet demo
    Linux Maven install
  • 原文地址:https://www.cnblogs.com/springyangwc/p/2293690.html
Copyright © 2011-2022 走看看