亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3827 | 回復(fù): 0
打印 上一主題 下一主題

remoting架構(gòu)探討 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-03-02 13:33 |只看該作者 |倒序瀏覽
轉(zhuǎn): HorsonJin


remoting架構(gòu)探討




1.remoting技術(shù)的特點
  remoting技術(shù)可以為分布式應(yīng)用提供強(qiáng)有力的支持,我們可以根據(jù)需求和特定的環(huán)境選擇合適的通道和序列化的方式滿足我們的應(yīng)用。另外remoting技術(shù)具有非常好的擴(kuò)展特性,我們甚至可以在remoting體系結(jié)構(gòu)的每個組件上進(jìn)行擴(kuò)展和自定義來滿足豐富的應(yīng)用需求。

2.環(huán)境分析

網(wǎng)絡(luò)環(huán)境分析
  假設(shè)公司是一家大型機(jī)構(gòu),內(nèi)部出于安全的需要,不同的部門和不同的子部分可能被不同的網(wǎng)絡(luò)防火墻隔離,但是不同的部門或者子部門需要共同協(xié)作來管理一些應(yīng)用,因此我們可能需要穿越公司內(nèi)部的防火墻來滿足我們的應(yīng)用需要。

軟件環(huán)境分析
  假設(shè)公司的大部分應(yīng)用建立在windows平臺之上,軟件大多運(yùn)行在clr之上,開發(fā)架構(gòu)采用主流的三層架構(gòu),服務(wù)方式采用c/s架構(gòu),出于安全考慮,公司拒絕非服務(wù)器IP直接訪問生產(chǎn)數(shù)據(jù)庫,同時可以預(yù)見的是需要處理大數(shù)據(jù)量,所以我們需要提供分布式處理來滿足公司安全方面的要求和達(dá)到良好的性能要求。

3.remoting架構(gòu)設(shè)計
通道選擇、激活方式、對象調(diào)用方式、傳輸方式選擇
  由于公司內(nèi)部網(wǎng)絡(luò)環(huán)境復(fù)雜,需要有較好的適應(yīng)能力,選擇httpchannel作為傳輸通道會有比較強(qiáng)的網(wǎng)絡(luò)環(huán)境適應(yīng)能力;激活方式采用服務(wù)端、singleton方式激活;業(yè)務(wù)操作類使用按址列集的方式進(jìn)行傳輸,實體對象使用按值列集的方式進(jìn)行傳輸。

解決方案設(shè)計
  在三層架構(gòu)的基礎(chǔ)上加上三個解決方案,分別為remoting服務(wù)端、remoting客戶端、IDL,建議將IDL的定義和實體類類的定義放在一個解決方案中。IDL的程序接需要分別被remoting服務(wù)端、remoting客戶端應(yīng)用。

示例代碼
IDL定義

  1. //接口定義

  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;

  5. namespace RemotingIDL
  6. {
  7.     public interface IService
  8.     {
  9.         OnlineOrder[] SayMessage(OnlineOrder o);
  10.         Sample SayMessage(Sample obj);
  11.     }
  12. }

  13. //實體類設(shè)計

  14. using System;
  15. using System.Collections.Generic;
  16. using System.Text;

  17. namespace RemotingIDL
  18. {
  19.     [Serializable]
  20.     public class Sample
  21.     {
  22.         private string message;

  23.         public string Message
  24.         {
  25.             get { return message; }
  26.             set { message = value; }
  27.         }

  28.     }
  29. }
復(fù)制代碼
業(yè)務(wù)操作類
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using RemotingIDL;
  5. public class MyService : MarshalByRefObject, IService
  6.     {
  7.         public OnlineOrder[] SayMessage(OnlineOrder o)
  8.         {
  9.             List<OnlineOrder> orders = new List<OnlineOrder>();
  10.             for (int i = 0; i < 10; i++)
  11.             {
  12.                 OnlineOrder order = new OnlineOrder();
  13.                 order.Message = o.Message;
  14.                 orders.Add(order);
  15.             }
  16.             Console.WriteLine("Record count:"+orders.Count);
  17.             return orders.ToArray();
  18.         }
  19.         public Sample SayMessage(Sample obj)
  20.         {
  21.             obj.Message = "this is a remoting invoke";
  22.             Console.WriteLine("this is a remoting serilizable!");
  23.             return obj;
  24.         }
  25.     }
復(fù)制代碼
服務(wù)端配置
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using RemotingIDL;
  5. using System.Runtime.Remoting;
  6. using System.Runtime.Remoting.Channels;
  7. using System.Runtime.Remoting.Channels.Tcp;
  8. using System.Runtime.Remoting.Channels.Http;
  9. namespace RemotingServer
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             HttpChannel http = new HttpChannel(81);
  16.             ChannelServices.RegisterChannel(http, false);
  17.             //RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService), "MyService", WellKnownObjectMode.Singleton);
  18.             RemotingConfiguration.RegisterWellKnownServiceType(typeof(ShoppingCart), "ShoppingCart", WellKnownObjectMode.Singleton);
  19.             Console.WriteLine("Remoting is running");
  20.             Console.ReadLine();
  21.         }
  22.     }
復(fù)制代碼
客戶端調(diào)用
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using RemotingIDL;
  5. using System.Runtime.Remoting;
  6. using System.Runtime.Remoting.Channels;
  7. using System.Runtime.Remoting.Channels.Tcp;
  8. using System.Runtime.Remoting.Channels.Http;

  9. namespace RemotingClient
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             try
  16.             {
  17.                 HttpChannel http = new HttpChannel();
  18.                 ChannelServices.RegisterChannel(http, false);
  19.                 IShoppingCart shoppingCart = (IShoppingCart)Activator.GetObject(typeof(IShoppingCart), "http://localhost:81/ShoppingCart");
  20.                 if (shoppingCart != null)
  21.                 {
  22.                     Product[] products = shoppingCart.GetProducts("Architecture");
  23.                     Console.WriteLine("Product count:" + products.Length.ToString());
  24.                 }
  25.             }
  26.             catch (System.Runtime.Serialization.SerializationException ex)
  27.             {
  28.                 Console.WriteLine(ex.Message);
  29.                 Console.WriteLine(ex.StackTrace);
  30.             }
  31.             catch (System.ArgumentException ex)
  32.             {
  33.                 Console.WriteLine(ex.Message);
  34.                 Console.WriteLine(ex.StackTrace);
  35.             }
  36.             Console.ReadLine();
  37.         }
  38.     }
  39. }
復(fù)制代碼
4.remoting設(shè)計中遇到的問題
list傳輸?shù)膯栴}

  在webservice中l(wèi)ist在默認(rèn)情況下被轉(zhuǎn)換為數(shù)組進(jìn)行傳輸,在remoting采用服務(wù)端、singleton方式激活的情況下,傳輸list直接拋出異常,不做默認(rèn)的轉(zhuǎn)換。

客戶端對象傳輸?shù)膯栴}

  在remoting采用服務(wù)端、singleton方式激活的情況下,客戶端對象按址列集傳輸時直接拋出異常,按值列集傳輸正常。

調(diào)試問題

  目前想到的調(diào)試方式:通過配置文件配置為調(diào)試狀態(tài)和發(fā)布狀態(tài),在調(diào)試狀態(tài)直接調(diào)用本地對象,只有在發(fā)布狀態(tài)才通過remoting調(diào)用遠(yuǎn)程對象。

本人初次使用remoting技術(shù)解決應(yīng)用需求的問題,還請大家多提寶貴意見,在此謝過了!
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP