Comprehensive evaluation of distributed communication schemes in C # and. Net

Source: Internet
Author: User

If you apply to an Internet Enterprise Architect distributed solutions are part of the question because the popular SOA is not nonsense about SOA. Online resources A lot of attention 4 words "based on message"

This article only evaluates the several commonly used in the project

Remoting (TCP,HTTP,IPC)

WCF (basichttpbinding,nettcpbinding)

Hessian

Msmq

WebService

......

Environment Introduction

Client Windows Xp server windows2003 (virtual machine)

Bandwidth 2M

test environment and online environment gap is larger we can see the relativity.

All scenarios are based on the same remote object

public class Dtoclass:marshalbyrefobject
{public
    static message Getmessageinfo (string param1, int param2, BOOL PARAM3)
    {
        var dto = new Message {Param1 = param1, Param2 = param2, Param3 = param3};
        return dto;
    }
     
}
     
[Serializable]
public class message
{public
    string Param1 {get; set;}
    public int Param2 {get; set;}
    public bool Param3 {get; set;}
     
}
     
Public interface imaoyatest
{message
    getdto (string param1, int param2, bool param3);
     
[ServiceContract]
Public interface iwcfmaoyatest
{
    [operationcontract] Message
    getdto (string param1, int param2, BOOL PARAM3);
}

Different communication scheme clients request the same object

such as remoting

Public message Tcpsinglecall ()
      {
          var proxy = (imaoyatest) Activator.GetObject (typeof (Imaoyatest), tcp:// 192.168.234.129:8001/maoyatesturl ");
          Return proxy. Getdto ("Chongzi", True);
     
      }

Hsssian

Public message hessiantest ()
        {
            var factory = new Chessianproxyfactory ("UserName", "password");
            Const string URL = "Http://192.168.234.129/HessianService.hessian";
            var hessianinstance = (imaoyatest) factory. Create (typeof (Imaoyatest), url);
            Return hessianinstance. Getdto ("Chongzi", True);
               
        }

Different communication schemes for different processing of remote objects

such as remoting

public class Remotingtest:marshalbyrefobject,imaoyatest
   {public message
       getdto (string param1, int param2, BOOL param3)
       {return
           dtoclass.getmessageinfo ("Remoting:" +PARAM1,PARAM2+1,PARAM3);
       }
   

Hsssian

public class Maoyaservice:chessianhandler, imaoyatest
   {public message
       getdto (string param1, int param2, BOOL PA RAM3)
       {return
           dtoclass.getmessageinfo ("Hessianservice:" + param1, param2 + 3, param3);
       }
   

This article URL address: http://www.bianceng.cn/Programming/csharp/201410/45482.htm

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.