├── .gitattributes ├── .gitignore ├── Distributed ├── Distributed.MessageQueue │ ├── Connection.cs │ ├── Distributed.MessageQueue.csproj │ ├── IConsumer.cs │ ├── IMessageQueueFactory.cs │ ├── IProducer.cs │ ├── Messages.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Providers │ │ └── Aliyun │ │ ├── AliyunConsumer.cs │ │ ├── AliyunMessage.cs │ │ ├── AliyunMessageQueueFactory.cs │ │ ├── AliyunMessageQueueFactoryOptions.cs │ │ └── AliyunProducer.cs ├── Distributed.SessionProvider.Memcached │ ├── Distributed.SessionProvider.Memcached.csproj │ ├── MemcachedSessionStateStoreProvider.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── Distributed.SessionProvider.Redis │ ├── Distributed.SessionProvider.Redis.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RedisSessionStateStoreProvider.cs │ └── packages.config ├── Distributed.Utility │ ├── Distributed.Utility.csproj │ ├── IDistributedLock.cs │ ├── Impl │ │ ├── ClrDistributedLock.cs │ │ └── MemcachedDistributedLock.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── Distributed.sln ├── Samples │ ├── MessageQueue │ │ ├── Consumer │ │ │ ├── App.config │ │ │ ├── Consumer.csproj │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ │ └── AssemblyInfo.cs │ │ └── Producer │ │ │ ├── App.config │ │ │ ├── Producer.csproj │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ └── SessionShared │ │ ├── WebApplication1 │ │ ├── Controllers │ │ │ └── HomeController.cs │ │ ├── Global.asax │ │ ├── Global.asax.cs │ │ ├── Models │ │ │ └── SetSessionModel.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Views │ │ │ ├── Home │ │ │ │ └── Index.cshtml │ │ │ └── Web.config │ │ ├── Web.Debug.config │ │ ├── Web.Release.config │ │ ├── Web.config │ │ ├── WebApplication1.csproj │ │ └── packages.config │ │ └── WebApplication2 │ │ ├── Controllers │ │ └── HomeController.cs │ │ ├── Global.asax │ │ ├── Global.asax.cs │ │ ├── Models │ │ └── GetSessionModel.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Views │ │ ├── Home │ │ │ └── Index.cshtml │ │ └── Web.config │ │ ├── Web.Debug.config │ │ ├── Web.Release.config │ │ ├── Web.config │ │ ├── WebApplication2.csproj │ │ └── packages.config └── lib │ └── MessageQueue │ └── ons │ ├── x64 │ ├── ManagedONS.dll │ └── ONSClient4CPP.dll │ └── x86 │ ├── ManagedONS.dll │ └── ONSClient4CPP.dll ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | build/ 19 | bld/ 20 | [Bb]in/ 21 | [Oo]bj/ 22 | 23 | # Visual Studo 2015 cache/options directory 24 | .vs/ 25 | 26 | # MSTest test Results 27 | [Tt]est[Rr]esult*/ 28 | [Bb]uild[Ll]og.* 29 | 30 | # NUNIT 31 | *.VisualState.xml 32 | TestResult.xml 33 | 34 | # Build Results of an ATL Project 35 | [Dd]ebugPS/ 36 | [Rr]eleasePS/ 37 | dlldata.c 38 | 39 | *_i.c 40 | *_p.c 41 | *_i.h 42 | *.ilk 43 | *.meta 44 | *.obj 45 | *.pch 46 | *.pdb 47 | *.pgc 48 | *.pgd 49 | *.rsp 50 | *.sbr 51 | *.tlb 52 | *.tli 53 | *.tlh 54 | *.tmp 55 | *.tmp_proj 56 | *.log 57 | *.vspscc 58 | *.vssscc 59 | .builds 60 | *.pidb 61 | *.svclog 62 | *.scc 63 | 64 | # Chutzpah Test files 65 | _Chutzpah* 66 | 67 | # Visual C++ cache files 68 | ipch/ 69 | *.aps 70 | *.ncb 71 | *.opensdf 72 | *.sdf 73 | *.cachefile 74 | 75 | # Visual Studio profiler 76 | *.psess 77 | *.vsp 78 | *.vspx 79 | 80 | # TFS 2012 Local Workspace 81 | $tf/ 82 | 83 | # Guidance Automation Toolkit 84 | *.gpState 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper*/ 88 | *.[Rr]e[Ss]harper 89 | *.DotSettings.user 90 | 91 | # JustCode is a .NET coding addin-in 92 | .JustCode 93 | 94 | # TeamCity is a build add-in 95 | _TeamCity* 96 | 97 | # DotCover is a Code Coverage Tool 98 | *.dotCover 99 | 100 | # NCrunch 101 | _NCrunch_* 102 | .*crunch*.local.xml 103 | 104 | # MightyMoose 105 | *.mm.* 106 | AutoTest.Net/ 107 | 108 | # Web workbench (sass) 109 | .sass-cache/ 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.[Pp]ublish.xml 129 | *.azurePubxml 130 | # TODO: Comment the next line if you want to checkin your web deploy settings 131 | # but database connection strings (with potential passwords) will be unencrypted 132 | *.pubxml 133 | *.publishproj 134 | 135 | # NuGet Packages 136 | *.nupkg 137 | # The packages folder can be ignored because of Package Restore 138 | **/packages/* 139 | # except build/, which is used as an MSBuild target. 140 | !**/packages/build/ 141 | # Uncomment if necessary however generally it will be regenerated when needed 142 | #!**/packages/repositories.config 143 | 144 | # Windows Azure Build Output 145 | csx/ 146 | *.build.csdef 147 | 148 | # Windows Store app package directory 149 | AppPackages/ 150 | 151 | # Others 152 | *.[Cc]ache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | bower_components/ 163 | 164 | # RIA/Silverlight projects 165 | Generated_Code/ 166 | 167 | # Backup & report files from converting an old project file 168 | # to a newer Visual Studio version. Backup files are not needed, 169 | # because we have git ;-) 170 | _UpgradeReport_Files/ 171 | Backup*/ 172 | UpgradeLog*.XML 173 | UpgradeLog*.htm 174 | 175 | # SQL Server files 176 | *.mdf 177 | *.ldf 178 | 179 | # Business Intelligence projects 180 | *.rdl.data 181 | *.bim.layout 182 | *.bim_*.settings 183 | 184 | # Microsoft Fakes 185 | FakesAssemblies/ 186 | 187 | # Node.js Tools for Visual Studio 188 | .ntvs_analysis.dat 189 | 190 | # Visual Studio 6 build log 191 | *.plg 192 | 193 | # Visual Studio 6 workspace options file 194 | *.opt 195 | -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Connection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Distributed.MessageQueue 5 | { 6 | public interface IConnection : IDisposable 7 | { 8 | Task Start(); 9 | 10 | Task Shutdown(); 11 | } 12 | 13 | internal abstract class Connection : IConnection 14 | { 15 | #region Field 16 | 17 | private bool _isStart; 18 | private bool _isShutdown; 19 | 20 | #endregion Field 21 | 22 | #region Implementation of IDisposable 23 | 24 | /// 25 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 26 | /// 27 | void IDisposable.Dispose() 28 | { 29 | try 30 | { 31 | if (_isShutdown) 32 | { 33 | lock (this) 34 | { 35 | if (_isShutdown) 36 | return; 37 | _isShutdown = true; 38 | } 39 | } 40 | Shutdown(); 41 | } 42 | finally 43 | { 44 | Dispose(); 45 | } 46 | } 47 | 48 | #endregion Implementation of IDisposable 49 | 50 | #region Implementation of IConnection 51 | 52 | async Task IConnection.Start() 53 | { 54 | if (_isStart) 55 | { 56 | lock (this) 57 | { 58 | if (_isStart) 59 | return; 60 | _isStart = true; 61 | } 62 | } 63 | await Task.Run(() => Start()); 64 | } 65 | 66 | async Task IConnection.Shutdown() 67 | { 68 | if (_isShutdown) 69 | { 70 | lock (this) 71 | { 72 | if (_isShutdown) 73 | return; 74 | _isShutdown = true; 75 | } 76 | } 77 | await Task.Run(() => Shutdown()); 78 | } 79 | 80 | #endregion Implementation of IConnection 81 | 82 | #region Protected Abstract Method 83 | 84 | protected abstract void Start(); 85 | 86 | protected abstract void Shutdown(); 87 | 88 | protected abstract void Dispose(); 89 | 90 | #endregion Protected Abstract Method 91 | } 92 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Distributed.MessageQueue.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {47D998DE-7110-4A51-A0F4-77BF8109D72A} 8 | Library 9 | Properties 10 | Distributed.MessageQueue 11 | Distributed.MessageQueue 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | x86 32 | 33 | 34 | true 35 | bin\x86\Debug\ 36 | DEBUG;TRACE 37 | full 38 | x86 39 | prompt 40 | MinimumRecommendedRules.ruleset 41 | 42 | 43 | bin\x86\Release\ 44 | TRACE 45 | true 46 | pdbonly 47 | x86 48 | prompt 49 | MinimumRecommendedRules.ruleset 50 | 51 | 52 | true 53 | bin\x64\Debug\ 54 | DEBUG;TRACE 55 | full 56 | x64 57 | prompt 58 | MinimumRecommendedRules.ruleset 59 | 60 | 61 | bin\x64\Release\ 62 | TRACE 63 | true 64 | pdbonly 65 | x64 66 | prompt 67 | MinimumRecommendedRules.ruleset 68 | 69 | 70 | 71 | ..\lib\MessageQueue\ons\x86\ManagedONS.dll 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/IConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Distributed.MessageQueue 4 | { 5 | public enum SubscribeAction 6 | { 7 | CommitMessage = 0, 8 | ReconsumeLater = 1 9 | } 10 | 11 | public interface IConsumer : IConnection 12 | { 13 | void Subscribe(string topic, string expression, Func func); 14 | } 15 | 16 | public static class ConsumerExtensions 17 | { 18 | public static void Subscribe(this IConsumer consumer, string topic, Func func) 19 | { 20 | consumer.Subscribe(topic, "*", func); 21 | } 22 | 23 | public static void Subscribe(this IConsumer consumer, string topic, string expression, Action action) 24 | { 25 | consumer.Subscribe(topic, expression, message => 26 | { 27 | action(message); 28 | return null; 29 | }); 30 | } 31 | 32 | public static void Subscribe(this IConsumer consumer, string topic, Action action) 33 | { 34 | consumer.Subscribe(topic, "*", action); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/IMessageQueueFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Distributed.MessageQueue 5 | { 6 | public interface IMessageQueueFactory : IDisposable 7 | { 8 | Task CreateConsumer(string consumerId); 9 | 10 | Task CreateProducer(string producerId); 11 | } 12 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/IProducer.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Distributed.MessageQueue 4 | { 5 | public class SendResult 6 | { 7 | public string MessageId { get; set; } 8 | } 9 | 10 | public interface IProducer : IConnection 11 | { 12 | Task Send(IResponseMessage message); 13 | } 14 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Messages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Distributed.MessageQueue 4 | { 5 | public interface IRequestMessage 6 | { 7 | string Body { get; } 8 | string Key { get; } 9 | string MessageId { get; } 10 | string Tag { get; } 11 | string Topic { get; } 12 | TimeSpan StartDeliverTime { get; } 13 | 14 | string GetUserProperty(string key); 15 | 16 | string GetSystemProperty(string key); 17 | } 18 | 19 | public interface IResponseMessage 20 | { 21 | string Body { set; } 22 | string Key { set; } 23 | string MessageId { set; } 24 | string Tag { set; } 25 | string Topic { set; } 26 | TimeSpan StartDeliverTime { set; } 27 | 28 | void PutUserProperty(string key, string value); 29 | 30 | void PutSystemProperty(string key, string value); 31 | } 32 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Distributed.MessageQueue")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Distributed.MessageQueue")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("47d998de-7110-4a51-a0f4-77bf8109d72a")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Providers/Aliyun/AliyunConsumer.cs: -------------------------------------------------------------------------------- 1 | using ons; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Distributed.MessageQueue.Providers.Aliyun 7 | { 8 | internal sealed class AliyunConsumer : Connection, IConsumer 9 | { 10 | #region Field 11 | 12 | private readonly PushConsumer _consumer; 13 | internal readonly IList> Funcs = new List>(); 14 | private bool _isSubscribe; 15 | 16 | #endregion Field 17 | 18 | #region Constructor 19 | 20 | public AliyunConsumer(PushConsumer consumer) 21 | { 22 | _consumer = consumer; 23 | } 24 | 25 | #endregion Constructor 26 | 27 | #region Overrides of Connection 28 | 29 | protected override void Start() 30 | { 31 | _consumer.start(); 32 | } 33 | 34 | protected override void Shutdown() 35 | { 36 | _consumer.shutdown(); 37 | } 38 | 39 | protected override void Dispose() 40 | { 41 | _consumer.Dispose(); 42 | } 43 | 44 | #endregion Overrides of Connection 45 | 46 | #region Implementation of IConsumer 47 | 48 | public void Subscribe(string topic, string expression, Func func) 49 | { 50 | if (!_isSubscribe) 51 | { 52 | lock (this) 53 | { 54 | if (!_isSubscribe) 55 | { 56 | MessageListener listener = new PrivateMessageListener(this); 57 | _consumer.subscribe(topic, expression, ref listener); 58 | _isSubscribe = true; 59 | } 60 | } 61 | } 62 | lock (this) 63 | { 64 | Funcs.Add(func); 65 | } 66 | } 67 | 68 | #endregion Implementation of IConsumer 69 | 70 | #region HelpClass 71 | 72 | private class PrivateMessageListener : MessageListener 73 | { 74 | private readonly AliyunConsumer _consumer; 75 | 76 | public PrivateMessageListener(AliyunConsumer consumer) 77 | { 78 | _consumer = consumer; 79 | } 80 | 81 | #region Overrides of MessageListener 82 | 83 | public override ons.Action consume(ref Message message) 84 | { 85 | var aliyunMessage = new AliyunMessage(message); 86 | 87 | lock (_consumer) 88 | { 89 | var action = _consumer.Funcs.Select(i => i(aliyunMessage)).ToArray().FirstOrDefault(i => i.HasValue); 90 | switch (action) 91 | { 92 | case null: 93 | case SubscribeAction.CommitMessage: 94 | return ons.Action.CommitMessage; 95 | 96 | case SubscribeAction.ReconsumeLater: 97 | return ons.Action.ReconsumeLater; 98 | 99 | default: 100 | throw new NotSupportedException($"不支持的动作类型:{action}。"); 101 | } 102 | } 103 | } 104 | 105 | #endregion Overrides of MessageListener 106 | } 107 | 108 | #endregion HelpClass 109 | } 110 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Providers/Aliyun/AliyunMessage.cs: -------------------------------------------------------------------------------- 1 | using ons; 2 | using System; 3 | 4 | namespace Distributed.MessageQueue.Providers.Aliyun 5 | { 6 | public sealed class AliyunMessage : IRequestMessage, IResponseMessage 7 | { 8 | internal readonly Message Message; 9 | 10 | public AliyunMessage() 11 | { 12 | Message = new Message(); 13 | } 14 | 15 | public AliyunMessage(Message message) 16 | { 17 | Message = message; 18 | } 19 | 20 | public string Body 21 | { 22 | get { return Message.getBody(); } 23 | set { Message.setBody(value); } 24 | } 25 | 26 | public string Key 27 | { 28 | get { return Message.getKey(); } 29 | set { Message.setKey(value); } 30 | } 31 | 32 | public string MessageId 33 | { 34 | get { return Message.getMsgID(); } 35 | set { Message.setMsgID(value); } 36 | } 37 | 38 | public string Tag 39 | { 40 | get { return Message.getTag(); } 41 | set { Message.setTag(value); } 42 | } 43 | 44 | public string Topic 45 | { 46 | get { return Message.getTopic(); } 47 | set { Message.setTopic(value); } 48 | } 49 | 50 | public TimeSpan StartDeliverTime 51 | { 52 | get { return TimeSpan.FromMilliseconds(Message.getStartDeliverTime()); } 53 | set { Message.setStartDeliverTime((long)value.TotalMilliseconds); } 54 | } 55 | 56 | #region Implementation of IRequestMessage 57 | 58 | public string GetUserProperty(string key) 59 | { 60 | return Message.getUserProperty(key); 61 | } 62 | 63 | public string GetSystemProperty(string key) 64 | { 65 | return Message.getSystemProperty(key); 66 | } 67 | 68 | #endregion Implementation of IRequestMessage 69 | 70 | #region Implementation of IResponseMessage 71 | 72 | public void PutUserProperty(string key, string value) 73 | { 74 | Message.putUserProperty(key, value); 75 | } 76 | 77 | public void PutSystemProperty(string key, string value) 78 | { 79 | Message.putSystemProperty(key, value); 80 | } 81 | 82 | #endregion Implementation of IResponseMessage 83 | } 84 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Providers/Aliyun/AliyunMessageQueueFactory.cs: -------------------------------------------------------------------------------- 1 | using ons; 2 | using System.Threading.Tasks; 3 | 4 | namespace Distributed.MessageQueue.Providers.Aliyun 5 | { 6 | public sealed class AliyunMessageQueueFactory : IMessageQueueFactory 7 | { 8 | #region Field 9 | 10 | private readonly ONSFactory _factory; 11 | private readonly ONSFactoryAPI _factoryInstance; 12 | private readonly ONSFactoryProperty _factoryProperty; 13 | 14 | #endregion Field 15 | 16 | #region Constructor 17 | 18 | public AliyunMessageQueueFactory(AliyunMessageQueueFactoryOptions options) 19 | { 20 | _factory = new ONSFactory(); 21 | _factoryInstance = _factory.getInstance(); 22 | _factoryProperty = GetOnsFactoryProperty(options); 23 | } 24 | 25 | #endregion Constructor 26 | 27 | #region Implementation of IDisposable 28 | 29 | /// 30 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 31 | /// 32 | public void Dispose() 33 | { 34 | _factoryInstance.Dispose(); 35 | _factory.Dispose(); 36 | _factoryProperty.Dispose(); 37 | } 38 | 39 | #endregion Implementation of IDisposable 40 | 41 | #region Implementation of IMessageQueueFactory 42 | 43 | public async Task CreateConsumer(string consumerId) 44 | { 45 | _factoryProperty.setFactoryProperty(_factoryProperty.getConsumerIdName(), "CID_" + consumerId); 46 | return await Task.Run(() => new AliyunConsumer(_factoryInstance.createPushConsumer(_factoryProperty))); 47 | } 48 | 49 | public async Task CreateProducer(string producerId) 50 | { 51 | _factoryProperty.setFactoryProperty(_factoryProperty.getProducerIdName(), "PID_" + producerId); 52 | return await Task.Run(() => new AliyunProducer(_factoryInstance.createProducer(_factoryProperty))); 53 | } 54 | 55 | #endregion Implementation of IMessageQueueFactory 56 | 57 | #region Private Method 58 | 59 | private static ONSFactoryProperty GetOnsFactoryProperty(AliyunMessageQueueFactoryOptions options) 60 | { 61 | var factoryInfo = new ONSFactoryProperty(); 62 | factoryInfo.setFactoryProperty(factoryInfo.getPublishTopicsName(), "null"); 63 | factoryInfo.setFactoryProperty(factoryInfo.getAccessKeyName(), options.AccessKey); 64 | factoryInfo.setFactoryProperty(factoryInfo.getSecretKeyName(), options.SecretKey); 65 | return factoryInfo; 66 | } 67 | 68 | #endregion Private Method 69 | } 70 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Providers/Aliyun/AliyunMessageQueueFactoryOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Distributed.MessageQueue.Providers.Aliyun 2 | { 3 | public sealed class AliyunMessageQueueFactoryOptions 4 | { 5 | public string AccessKey { get; set; } 6 | public string SecretKey { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Distributed/Distributed.MessageQueue/Providers/Aliyun/AliyunProducer.cs: -------------------------------------------------------------------------------- 1 | using ons; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace Distributed.MessageQueue.Providers.Aliyun 6 | { 7 | internal sealed class AliyunProducer : Connection, IProducer 8 | { 9 | #region Field 10 | 11 | private readonly Producer _producer; 12 | 13 | #endregion Field 14 | 15 | #region Constructor 16 | 17 | public AliyunProducer(Producer producer) 18 | { 19 | _producer = producer; 20 | } 21 | 22 | #endregion Constructor 23 | 24 | #region Overrides of Connection 25 | 26 | protected override void Start() 27 | { 28 | _producer.start(); 29 | } 30 | 31 | protected override void Shutdown() 32 | { 33 | _producer.shutdown(); 34 | } 35 | 36 | protected override void Dispose() 37 | { 38 | _producer.Dispose(); 39 | } 40 | 41 | #endregion Overrides of Connection 42 | 43 | #region Implementation of IProducer 44 | 45 | public async Task Send(IResponseMessage message) 46 | { 47 | if (message == null) 48 | throw new NullReferenceException(nameof(message)); 49 | 50 | var aliyunMessage = message as AliyunMessage; 51 | 52 | if (aliyunMessage == null) 53 | throw new NotSupportedException($"当前发布者提供程序:{GetType().FullName},无法发送类型为:{message.GetType().FullName}的消息。"); 54 | if (string.IsNullOrWhiteSpace(aliyunMessage.Topic)) 55 | throw new ArgumentException("消息主题(Topic)不能为空!"); 56 | if (string.IsNullOrWhiteSpace(aliyunMessage.Body)) 57 | throw new ArgumentException("消息主体(Body)不能为空!"); 58 | 59 | return await Task.Run(() => 60 | { 61 | using (var result = _producer.send(aliyunMessage.Message)) 62 | { 63 | return new SendResult { MessageId = result.getMessageId() }; 64 | } 65 | }); 66 | } 67 | 68 | #endregion Implementation of IProducer 69 | } 70 | } -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Memcached/Distributed.SessionProvider.Memcached.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E89B22B4-6CE8-4533-AC08-EA17A722545F} 8 | Library 9 | Properties 10 | Distributed.SessionProvider.Memcached 11 | Distributed.SessionProvider.Memcached 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\EnyimMemcached.2.13\lib\net35\Enyim.Caching.dll 35 | True 36 | 37 | 38 | ..\packages\Newtonsoft.Json.6.0.4\lib\net40\Newtonsoft.Json.dll 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Memcached/MemcachedSessionStateStoreProvider.cs: -------------------------------------------------------------------------------- 1 | using Enyim.Caching; 2 | using Enyim.Caching.Configuration; 3 | using Enyim.Caching.Memcached; 4 | using Newtonsoft.Json; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Configuration; 8 | using System.Diagnostics; 9 | using System.Web; 10 | using System.Web.SessionState; 11 | 12 | namespace Distributed.SessionProvider.Memcached 13 | { 14 | public sealed class MemcachedSessionStateStoreProvider : SessionStateStoreProviderBase 15 | { 16 | #region Field 17 | 18 | private static readonly Lazy MemcachedClient; 19 | private static readonly string SessionKey; 20 | 21 | #endregion Field 22 | 23 | #region Constructor 24 | 25 | static MemcachedSessionStateStoreProvider() 26 | { 27 | SessionKey = ConfigurationManager.AppSettings["MemcachedSessionKey"] ?? "MemcachedSession"; 28 | MemcachedClient = new Lazy(() => 29 | { 30 | var configuration = new MemcachedClientConfiguration(); 31 | configuration.AddServer(ConfigurationManager.AppSettings["MemcachedServerAddress"]); 32 | configuration.Protocol = MemcachedProtocol.Binary; 33 | return new MemcachedClient(configuration); 34 | }); 35 | } 36 | 37 | #endregion Constructor 38 | 39 | #region Overrides of SessionStateStoreProviderBase 40 | 41 | /// 42 | /// 释放由 实现使用的所有资源。 43 | /// 44 | public override void Dispose() 45 | { 46 | } 47 | 48 | /// 49 | /// 设置对 Global.asax 文件中定义的 Session_OnEnd 事件的 委托的引用。 50 | /// 51 | /// 52 | /// 如果会话状态存储提供程序支持调用 Session_OnEnd 事件,则为 true;否则为 false。 53 | /// 54 | /// 对 Global.asax 文件中定义的 Session_OnEnd 事件的 委托。 55 | public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback) 56 | { 57 | return true; 58 | } 59 | 60 | /// 61 | /// 由 对象调用,以便进行每次请求初始化。 62 | /// 63 | /// 当前请求的 。 64 | public override void InitializeRequest(HttpContext context) 65 | { 66 | } 67 | 68 | /// 69 | /// 从会话数据存储区中返回只读会话状态数据。 70 | /// 71 | /// 72 | /// 使用会话数据存储区中的会话值和信息填充的 。 73 | /// 74 | /// 当前请求的 当前请求的 当此方法返回时,如果请求的会话项在会话数据存储区被锁定,请包含一个设置为 true 的布尔值;否则请包含一个设置为 false 的布尔值。当此方法返回时,请包含一个设置为会话数据存储区中的项锁定时间的 对象。当此方法返回时,请包含一个设置为当前请求的锁定标识符的对象。有关锁定标识符的详细信息,请参见 类摘要中的“锁定会话存储区数据”。当此方法返回时,请包含 值之一,指示当前会话是否为未初始化的无 Cookie 会话。 75 | public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, 76 | out SessionStateActions actions) 77 | { 78 | return DoGet(context, id, false, out locked, out lockAge, out lockId, out actions); 79 | } 80 | 81 | /// 82 | /// 从会话数据存储区中返回只读会话状态数据。 83 | /// 84 | /// 85 | /// 使用会话数据存储区中的会话值和信息填充的 。 86 | /// 87 | /// 当前请求的 当前请求的 当此方法返回时,如果成功获得锁定,请包含一个设置为 true 的布尔值;否则请包含一个设置为 false 的布尔值。当此方法返回时,请包含一个设置为会话数据存储区中的项锁定时间的 对象。当此方法返回时,请包含一个设置为当前请求的锁定标识符的对象。有关锁定标识符的详细信息,请参见 类摘要中的“锁定会话存储区数据”。当此方法返回时,请包含 值之一,指示当前会话是否为未初始化的无 Cookie 会话。 88 | public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, 89 | out object lockId, out SessionStateActions actions) 90 | { 91 | return DoGet(context, id, true, out locked, out lockAge, out lockId, out actions); 92 | } 93 | 94 | /// 95 | /// 释放对会话数据存储区中项的锁定。 96 | /// 97 | /// 当前请求的 当前请求的会话标识符。当前请求的锁定标识符。 98 | public override void ReleaseItemExclusive(HttpContext context, string id, object lockId) 99 | { 100 | } 101 | 102 | /// 103 | /// 使用当前请求中的值更新会话状态数据存储区中的会话项信息,并清除对数据的锁定。 104 | /// 105 | /// 当前请求的 当前请求的会话标识符。包含要存储的当前会话值的 对象。当前请求的锁定标识符。如果为 true,则将会话项标识为新项;如果为 false,则将会话项标识为现有的项。 106 | public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem) 107 | { 108 | new MemcachedSessionStateStore(MemcachedClient.Value).Set(id, item.Timeout, item.Items); 109 | } 110 | 111 | /// 112 | /// 删除会话数据存储区中的项数据。 113 | /// 114 | /// 当前请求的 当前请求的会话标识符。当前请求的锁定标识符。表示将从数据存储区中删除的项的 。 115 | public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item) 116 | { 117 | new MemcachedSessionStateStore(MemcachedClient.Value).Delete(id); 118 | } 119 | 120 | /// 121 | /// 更新会话数据存储区中的项的到期日期和时间。 122 | /// 123 | /// 当前请求的 当前请求的会话标识符。 124 | public override void ResetItemTimeout(HttpContext context, string id) 125 | { 126 | } 127 | 128 | /// 129 | /// 创建要用于当前请求的新 对象。 130 | /// 131 | /// 132 | /// 当前请求的新 。 133 | /// 134 | /// 当前请求的 的会话状态 值。 135 | public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout) 136 | { 137 | return CreateLegitStoreData(context, null, null, timeout); 138 | } 139 | 140 | /// 141 | /// 将新的会话状态项添加到数据存储区中。 142 | /// 143 | /// 当前请求的 当前请求的 当前请求的会话 。 144 | public override void CreateUninitializedItem(HttpContext context, string id, int timeout) 145 | { 146 | } 147 | 148 | /// 149 | /// 在请求结束时由 对象调用。 150 | /// 151 | /// 当前请求的 。 152 | public override void EndRequest(HttpContext context) 153 | { 154 | } 155 | 156 | #endregion Overrides of SessionStateStoreProviderBase 157 | 158 | #region Private Method 159 | 160 | private static SessionStateStoreData CreateLegitStoreData(HttpContext context, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout) 161 | { 162 | if (sessionItems == null) 163 | sessionItems = new SessionStateItemCollection(); 164 | if (staticObjects == null && context != null) 165 | staticObjects = SessionStateUtility.GetSessionStaticObjects(context); 166 | return new SessionStateStoreData(sessionItems, staticObjects, timeout); 167 | } 168 | 169 | private SessionStateStoreData DoGet(HttpContext context, string id, bool exclusive, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actionFlags) 170 | { 171 | locked = false; 172 | lockId = null; 173 | lockAge = TimeSpan.Zero; 174 | actionFlags = SessionStateActions.None; 175 | 176 | int timeout; 177 | var sessionStateItemCollection = new MemcachedSessionStateStore(MemcachedClient.Value).Get(id, out timeout); 178 | 179 | return CreateLegitStoreData(context, sessionStateItemCollection, null, timeout); 180 | } 181 | 182 | #endregion Private Method 183 | 184 | #region Help Class 185 | 186 | public sealed class MemcachedSessionStateStore 187 | { 188 | private readonly IMemcachedClient _client; 189 | 190 | public MemcachedSessionStateStore(IMemcachedClient client) 191 | { 192 | _client = client; 193 | } 194 | 195 | [Serializable] 196 | public sealed class SessionEntry 197 | { 198 | public SessionEntry() : this(20) 199 | { 200 | } 201 | 202 | public SessionEntry(int timeout) 203 | { 204 | Timeout = timeout; 205 | Dictionary = new Dictionary(); 206 | } 207 | 208 | public int Timeout { get; set; } 209 | public IDictionary Dictionary { get; set; } 210 | 211 | [Serializable] 212 | public sealed class DataItem 213 | { 214 | public DataItem(object value) 215 | { 216 | if (value == null) 217 | return; 218 | Json = JsonConvert.SerializeObject(value); 219 | var type = value.GetType(); 220 | AssemblyQualifiedName = type.AssemblyQualifiedName; 221 | } 222 | 223 | /// 224 | /// 对象Json序列化后的内容。 225 | /// 226 | public string Json { get; set; } 227 | 228 | /// 229 | /// 对象类型的程序集限定名。 230 | /// 231 | public string AssemblyQualifiedName { get; set; } 232 | 233 | public string Serialize() 234 | { 235 | return JsonConvert.SerializeObject(this); 236 | } 237 | 238 | /// 239 | /// 反序列化。 240 | /// 241 | /// 对象实例。 242 | public object Deserialize() 243 | { 244 | if (string.IsNullOrEmpty(AssemblyQualifiedName) || string.IsNullOrEmpty(Json)) 245 | return null; 246 | 247 | try 248 | { 249 | return JsonConvert.DeserializeObject(Json, Type.GetType(AssemblyQualifiedName)); 250 | } 251 | catch (Exception exception) 252 | { 253 | Debug.WriteLine($"反序列化Session中的对象发送了错误,{exception.Message}。"); 254 | return null; 255 | } 256 | } 257 | 258 | public static DataItem Create(string json) 259 | { 260 | return JsonConvert.DeserializeObject(json); 261 | } 262 | } 263 | } 264 | 265 | public ISessionStateItemCollection Get(string id, out int timeout) 266 | { 267 | var key = GetKey(id); 268 | var entry = _client.Get(key); 269 | 270 | ISessionStateItemCollection sessionStateItemCollection = new SessionStateItemCollection(); 271 | 272 | if (entry == null) 273 | { 274 | entry = new SessionEntry(); 275 | } 276 | else 277 | { 278 | foreach (var item in entry.Dictionary) 279 | { 280 | sessionStateItemCollection[item.Key] = item.Value.Deserialize(); 281 | } 282 | } 283 | 284 | timeout = entry.Timeout; 285 | 286 | //更新过期时间。 287 | _client.Store(StoreMode.Set, key, entry, TimeSpan.FromMinutes(timeout)); 288 | 289 | return sessionStateItemCollection; 290 | } 291 | 292 | public void Set(string id, int timeout, ISessionStateItemCollection sessionStateItemCollection) 293 | { 294 | var sessionKey = GetKey(id); 295 | var entry = _client.Get(sessionKey) ?? new SessionEntry(timeout); 296 | 297 | foreach (string key in sessionStateItemCollection.Keys) 298 | entry.Dictionary[key] = new SessionEntry.DataItem(sessionStateItemCollection[key]); 299 | 300 | //保存。 301 | _client.Store(StoreMode.Set, sessionKey, entry, TimeSpan.FromMinutes(timeout)); 302 | } 303 | 304 | public void Delete(string id) 305 | { 306 | _client.Remove(GetKey(id)); 307 | } 308 | 309 | #region Private Method 310 | 311 | private static string GetKey(string sessionId) 312 | { 313 | return SessionKey + "_" + sessionId; 314 | } 315 | 316 | #endregion Private Method 317 | } 318 | 319 | #endregion Help Class 320 | } 321 | } -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Memcached/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Distributed.SessionProvider.Memcached")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Distributed.SessionProvider.Memcached")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("e89b22b4-6ce8-4533-ac08-ea17a722545f")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.2.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Memcached/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Redis/Distributed.SessionProvider.Redis.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96} 8 | Library 9 | Properties 10 | Distributed.SessionProvider.Redis 11 | Distributed.SessionProvider.Redis 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x86\Debug\ 38 | DEBUG;TRACE 39 | full 40 | x86 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\x86\Release\ 46 | TRACE 47 | true 48 | pdbonly 49 | x86 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | true 55 | bin\x64\Debug\ 56 | DEBUG;TRACE 57 | full 58 | x64 59 | prompt 60 | MinimumRecommendedRules.ruleset 61 | 62 | 63 | bin\x64\Release\ 64 | TRACE 65 | true 66 | pdbonly 67 | x64 68 | prompt 69 | MinimumRecommendedRules.ruleset 70 | 71 | 72 | 73 | ..\packages\Newtonsoft.Json.6.0.4\lib\net40\Newtonsoft.Json.dll 74 | True 75 | 76 | 77 | ..\packages\StackExchange.Redis.1.0.481\lib\net45\StackExchange.Redis.dll 78 | True 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Redis/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Distributed.SessionProvider.Redis")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Distributed.SessionProvider.Redis")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("f4950134-b5d7-4246-9dc7-ea89d6f18f96")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Redis/RedisSessionStateStoreProvider.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using StackExchange.Redis; 4 | using System; 5 | using System.Configuration; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Web; 9 | using System.Web.SessionState; 10 | 11 | namespace Distributed.SessionProvider.Redis 12 | { 13 | public class RedisSessionStateStoreProvider : SessionStateStoreProviderBase 14 | { 15 | #region Field 16 | 17 | private static readonly ConnectionMultiplexer ConnectionMultiplexer; 18 | 19 | #endregion Field 20 | 21 | #region Constructor 22 | 23 | static RedisSessionStateStoreProvider() 24 | { 25 | ConnectionMultiplexer = ConnectionMultiplexer.Connect(new ConfigurationOptions 26 | { 27 | EndPoints = { ConfigurationManager.AppSettings["RedisServer"] }, 28 | ConnectTimeout = 30 * 1000 29 | }); 30 | } 31 | 32 | #endregion Constructor 33 | 34 | #region Overrides of SessionStateStoreProviderBase 35 | 36 | /// 37 | /// Releases all resources used by the implementation. 38 | /// 39 | public override void Dispose() 40 | { 41 | } 42 | 43 | /// 44 | /// Sets a reference to the delegate for the Session_OnEnd event defined in the Global.asax file. 45 | /// 46 | /// 47 | /// true if the session-state store provider supports calling the Session_OnEnd event; otherwise, false. 48 | /// 49 | /// The delegate for the Session_OnEnd event defined in the Global.asax file. 50 | public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback) 51 | { 52 | return true; 53 | } 54 | 55 | /// 56 | /// Called by the object for per-request initialization. 57 | /// 58 | /// The for the current request. 59 | public override void InitializeRequest(HttpContext context) 60 | { 61 | } 62 | 63 | /// 64 | /// Returns read-only session-state data from the session data store. 65 | /// 66 | /// 67 | /// A populated with session values and information from the session data store. 68 | /// 69 | /// The for the current request.The for the current request.When this method returns, contains a Boolean value that is set to true if the requested session item is locked at the session data store; otherwise, false.When this method returns, contains a object that is set to the amount of time that an item in the session data store has been locked.When this method returns, contains an object that is set to the lock identifier for the current request. For details on the lock identifier, see "Locking Session-Store Data" in the class summary.When this method returns, contains one of the values, indicating whether the current session is an uninitialized, cookieless session. 70 | public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, 71 | out SessionStateActions actions) 72 | { 73 | return DoGet(context, id, false, out locked, out lockAge, out lockId, out actions); 74 | } 75 | 76 | /// 77 | /// Returns read-only session-state data from the session data store. 78 | /// 79 | /// 80 | /// A populated with session values and information from the session data store. 81 | /// 82 | /// The for the current request.The for the current request.When this method returns, contains a Boolean value that is set to true if a lock is successfully obtained; otherwise, false.When this method returns, contains a object that is set to the amount of time that an item in the session data store has been locked.When this method returns, contains an object that is set to the lock identifier for the current request. For details on the lock identifier, see "Locking Session-Store Data" in the class summary.When this method returns, contains one of the values, indicating whether the current session is an uninitialized, cookieless session. 83 | public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, 84 | out object lockId, out SessionStateActions actions) 85 | { 86 | return DoGet(context, id, true, out locked, out lockAge, out lockId, out actions); 87 | } 88 | 89 | /// 90 | /// Releases a lock on an item in the session data store. 91 | /// 92 | /// The for the current request.The session identifier for the current request.The lock identifier for the current request. 93 | public override void ReleaseItemExclusive(HttpContext context, string id, object lockId) 94 | { 95 | } 96 | 97 | /// 98 | /// Updates the session-item information in the session-state data store with values from the current request, and clears the lock on the data. 99 | /// 100 | /// The for the current request.The session identifier for the current request.The object that contains the current session values to be stored.The lock identifier for the current request. true to identify the session item as a new item; false to identify the session item as an existing item. 101 | public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem) 102 | { 103 | ISessionStateItemCollection sessionItems = null; 104 | 105 | if (item.Items.Count > 0) 106 | sessionItems = item.Items; 107 | 108 | var database = GetConnection().GetDatabase(); 109 | RedisSessionStateStore.Create(database, id, item.Timeout).Set(sessionItems); 110 | } 111 | 112 | /// 113 | /// Deletes item data from the session data store. 114 | /// 115 | /// The for the current request.The session identifier for the current request.The lock identifier for the current request.The that represents the item to delete from the data store. 116 | public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item) 117 | { 118 | var database = GetConnection().GetDatabase(); 119 | RedisSessionStateStore.Delete(database, id); 120 | } 121 | 122 | /// 123 | /// Updates the expiration date and time of an item in the session data store. 124 | /// 125 | /// The for the current request.The session identifier for the current request. 126 | public override void ResetItemTimeout(HttpContext context, string id) 127 | { 128 | } 129 | 130 | /// 131 | /// Creates a new object to be used for the current request. 132 | /// 133 | /// 134 | /// A new for the current request. 135 | /// 136 | /// The for the current request.The session-state value for the new . 137 | public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout) 138 | { 139 | return CreateLegitStoreData(context, null, null, timeout); 140 | } 141 | 142 | /// 143 | /// Adds a new session-state item to the data store. 144 | /// 145 | /// The for the current request.The for the current request.The session for the current request. 146 | public override void CreateUninitializedItem(HttpContext context, string id, int timeout) 147 | { 148 | var database = GetConnection().GetDatabase(); 149 | RedisSessionStateStore.Create(database, id, timeout); 150 | } 151 | 152 | /// 153 | /// Called by the object at the end of a request. 154 | /// 155 | /// The for the current request. 156 | public override void EndRequest(HttpContext context) 157 | { 158 | } 159 | 160 | #endregion Overrides of SessionStateStoreProviderBase 161 | 162 | #region Private Method 163 | 164 | private static ConnectionMultiplexer GetConnection() 165 | { 166 | return ConnectionMultiplexer; 167 | } 168 | 169 | private static SessionStateStoreData CreateLegitStoreData(HttpContext context, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout) 170 | { 171 | if (sessionItems == null) 172 | sessionItems = new SessionStateItemCollection(); 173 | if (staticObjects == null && context != null) 174 | staticObjects = SessionStateUtility.GetSessionStaticObjects(context); 175 | return new SessionStateStoreData(sessionItems, staticObjects, timeout); 176 | } 177 | 178 | private SessionStateStoreData DoGet(HttpContext context, string id, bool exclusive, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actionFlags) 179 | { 180 | locked = false; 181 | lockId = null; 182 | lockAge = TimeSpan.Zero; 183 | actionFlags = SessionStateActions.None; 184 | var database = GetConnection().GetDatabase(); 185 | var state = RedisSessionStateStore.Get(database, id); 186 | if (state == null) 187 | return null; 188 | state.UpdateExpire(); 189 | return CreateLegitStoreData(context, state.GetSessionStateItemCollection(), null, (int)state.Timeout.TotalMinutes); 190 | } 191 | 192 | #endregion Private Method 193 | 194 | #region Help Class 195 | 196 | internal sealed class RedisSessionStateStore 197 | { 198 | #region Field 199 | 200 | private readonly IDatabase _database; 201 | private readonly string _id; 202 | 203 | #endregion Field 204 | 205 | #region Constructor 206 | 207 | private RedisSessionStateStore(IDatabase database, string id, TimeSpan timeout, string hashKey) 208 | { 209 | Timeout = timeout; 210 | HashKey = hashKey; 211 | _database = database; 212 | _id = id; 213 | } 214 | 215 | #endregion Constructor 216 | 217 | #region Property 218 | 219 | public TimeSpan Timeout { get; } 220 | public string HashKey { get; } 221 | 222 | #endregion Property 223 | 224 | #region Public Method 225 | 226 | public ISessionStateItemCollection GetSessionStateItemCollection() 227 | { 228 | var hash = _database.HashGetAll(HashKey); 229 | ISessionStateItemCollection collection = new SessionStateItemCollection(); 230 | 231 | foreach (var entry in hash) 232 | { 233 | var item = JsonConvert.DeserializeObject(entry.Value); 234 | collection[entry.Name] = item?.Deserialize(); 235 | } 236 | return collection; 237 | } 238 | 239 | public void Set(ISessionStateItemCollection sessionStateItemCollection) 240 | { 241 | _database.KeyDelete(HashKey); 242 | if (sessionStateItemCollection == null) 243 | return; 244 | foreach (string key in sessionStateItemCollection.Keys) 245 | { 246 | var item = sessionStateItemCollection[key]; 247 | _database.HashSet(HashKey, key, item == null ? null : JsonConvert.SerializeObject(new DataItem(item))); 248 | } 249 | 250 | UpdateExpire(); 251 | } 252 | 253 | public void UpdateExpire() 254 | { 255 | UpdateExpire(_database, _id, Timeout); 256 | } 257 | 258 | #endregion Public Method 259 | 260 | #region Public Static Method 261 | 262 | public static RedisSessionStateStore Create(IDatabase database, string id, int timeout) 263 | { 264 | var timeoutSpan = TimeSpan.FromMinutes(timeout); 265 | database.StringSet(id, JsonConvert.SerializeObject(new { Timeout = timeout }), timeoutSpan); 266 | 267 | var hashKey = GetHashKey(id); 268 | var entrys = database.HashGetAll(hashKey); 269 | foreach (var entry in entrys) 270 | database.HashDelete(hashKey, entry.Name); 271 | 272 | return new RedisSessionStateStore(database, id, TimeSpan.FromMinutes(timeout), hashKey); 273 | } 274 | 275 | public static RedisSessionStateStore Get(IDatabase database, string id) 276 | { 277 | var json = database.StringGet(id); 278 | 279 | int timeout; 280 | 281 | try 282 | { 283 | var jobject = JObject.Parse(json); 284 | timeout = jobject.Value("Timeout"); 285 | } 286 | catch (Exception) 287 | { 288 | timeout = 20; 289 | } 290 | 291 | return new RedisSessionStateStore(database, id, TimeSpan.FromMinutes(timeout), GetHashKey(id)); 292 | } 293 | 294 | public static void Delete(IDatabase database, string id) 295 | { 296 | database.KeyDelete(new RedisKey[] { id, GetHashKey(id) }); 297 | } 298 | 299 | public static void UpdateExpire(IDatabase database, string id, TimeSpan timeout) 300 | { 301 | var keys = new[] { id, GetHashKey(id) }; 302 | foreach (var key in keys.Where(key => database.KeyExists(key))) 303 | { 304 | database.KeyExpire(key, timeout); 305 | } 306 | } 307 | 308 | private static string GetHashKey(string id) 309 | { 310 | return "Hash_" + id; 311 | } 312 | 313 | #endregion Public Static Method 314 | 315 | #region Help Class 316 | 317 | internal sealed class DataItem 318 | { 319 | public DataItem() 320 | { 321 | } 322 | 323 | public DataItem(object value) 324 | { 325 | if (value == null) 326 | return; 327 | Json = JsonConvert.SerializeObject(value); 328 | var type = value.GetType(); 329 | AssemblyQualifiedName = type.AssemblyQualifiedName; 330 | } 331 | 332 | /// 333 | /// 对象Json序列化后的内容。 334 | /// 335 | public string Json { get; set; } 336 | 337 | /// 338 | /// 对象类型的程序集限定名。 339 | /// 340 | public string AssemblyQualifiedName { get; set; } 341 | 342 | /// 343 | /// 反序列化。 344 | /// 345 | /// 对象实例。 346 | public object Deserialize() 347 | { 348 | if (string.IsNullOrEmpty(AssemblyQualifiedName) || string.IsNullOrEmpty(Json)) 349 | return null; 350 | 351 | try 352 | { 353 | return JsonConvert.DeserializeObject(Json, Type.GetType(AssemblyQualifiedName)); 354 | } 355 | catch (Exception exception) 356 | { 357 | Debug.WriteLine($"反序列化Session中的对象发送了错误,{exception.Message}。"); 358 | return null; 359 | } 360 | } 361 | } 362 | 363 | #endregion Help Class 364 | } 365 | 366 | #endregion Help Class 367 | } 368 | } -------------------------------------------------------------------------------- /Distributed/Distributed.SessionProvider.Redis/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/Distributed.Utility.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8578877A-B2C1-4321-BB11-A7AE1FECF948} 8 | Library 9 | Properties 10 | Distributed.Utility 11 | Distributed.Utility 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | bin\Release\Distributed.Utility.XML 32 | 33 | 34 | 35 | ..\packages\EnyimMemcached.2.13\lib\net35\Enyim.Caching.dll 36 | True 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 64 | -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/IDistributedLock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Distributed.Utility 4 | { 5 | /// 6 | /// 一个抽象的分布式锁控制器。 7 | /// 8 | public interface IDistributedLock 9 | { 10 | /// 11 | /// 锁定(超时时间为30秒)。 12 | /// 13 | /// 锁记号。 14 | void Lock(string token); 15 | 16 | /// 17 | /// 尝试锁定。 18 | /// 19 | /// 锁记号。 20 | /// 超时时间。 21 | void TryLock(string token, TimeSpan timeout); 22 | 23 | /// 24 | /// 解锁。 25 | /// 26 | /// 锁记号。 27 | void UnLock(string token); 28 | } 29 | } -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/Impl/ClrDistributedLock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Threading; 4 | 5 | namespace Distributed.Utility.Impl 6 | { 7 | /// 8 | /// 基于Monitor的分布式锁。 9 | /// 10 | public sealed class ClrDistributedLock : IDistributedLock 11 | { 12 | private readonly ConcurrentDictionary _dictionary = new ConcurrentDictionary(); 13 | 14 | #region Implementation of IDistributedLock 15 | 16 | /// 17 | /// 锁定(超时时间为30秒)。 18 | /// 19 | /// 锁记号。 20 | public void Lock(string token) 21 | { 22 | TryLock(token, TimeSpan.FromSeconds(10)); 23 | } 24 | 25 | /// 26 | /// 尝试锁定。 27 | /// 28 | /// 锁记号。 29 | /// 超时时间。 30 | public void TryLock(string token, TimeSpan timeout) 31 | { 32 | var syncLock = _dictionary.GetOrAdd(token, key => new object()); 33 | Monitor.TryEnter(syncLock, timeout); 34 | } 35 | 36 | /// 37 | /// 解锁。 38 | /// 39 | /// 锁记号。 40 | public void UnLock(string token) 41 | { 42 | object syncLock; 43 | if (_dictionary.TryRemove(token, out syncLock)) 44 | Monitor.Exit(syncLock); 45 | } 46 | 47 | #endregion Implementation of IDistributedLock 48 | } 49 | } -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/Impl/MemcachedDistributedLock.cs: -------------------------------------------------------------------------------- 1 | using Enyim.Caching; 2 | using Enyim.Caching.Memcached; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading; 7 | 8 | namespace Distributed.Utility.Impl 9 | { 10 | /// 11 | /// 基于Memcached的分布式锁实现。 12 | /// 13 | public sealed class MemcachedDistributedLock : IDistributedLock 14 | { 15 | #region Field 16 | 17 | private const string DistributedLockGroupKey = "Distributed.Utility.DistributedLocks"; 18 | private readonly IMemcachedClient _client; 19 | private static readonly object MemcachedSyncLock = new object(); 20 | 21 | #endregion Field 22 | 23 | #region Constructor 24 | 25 | /// 26 | /// 初始化一个新的基于Memcached的分布式锁。 27 | /// 28 | /// Memcached客户端。 29 | public MemcachedDistributedLock(IMemcachedClient client) 30 | { 31 | _client = client; 32 | } 33 | 34 | #endregion Constructor 35 | 36 | #region Implementation of IDistributedLock 37 | 38 | /// 39 | /// 锁定(超时时间为30秒)。 40 | /// 41 | /// 锁记号。 42 | public void Lock(string token) 43 | { 44 | TryLock(token, TimeSpan.FromSeconds(30)); 45 | } 46 | 47 | /// 48 | /// 尝试锁定。 49 | /// 50 | /// 锁记号。 51 | /// 超时时间。 52 | public void TryLock(string token, TimeSpan timeout) 53 | { 54 | var startTime = DateTime.Now; 55 | 56 | lock (MemcachedSyncLock) 57 | { 58 | var runTime = DateTime.Now.Subtract(startTime); 59 | while (true) 60 | { 61 | var tokens = GetTokens(); 62 | //锁已经存在执行。 63 | if (tokens.Contains(token)) 64 | { 65 | const int waitTime = 50; 66 | Thread.Sleep(waitTime); 67 | runTime = runTime.Add(TimeSpan.FromMilliseconds(waitTime)); 68 | if (runTime >= timeout) 69 | throw new TimeoutException("请求分布式锁超时!"); 70 | continue; 71 | } 72 | 73 | //存入锁。 74 | if (Store(tokens.Concat(new[] { token }).ToArray())) 75 | break; 76 | } 77 | } 78 | } 79 | 80 | /// 81 | /// 解锁。 82 | /// 83 | /// 锁记号。 84 | public void UnLock(string token) 85 | { 86 | lock (MemcachedSyncLock) 87 | { 88 | var tokens = GetTokens(); 89 | 90 | if (!tokens.Contains(token)) 91 | return; 92 | if (!Store(tokens.Where(i => i != token))) 93 | throw new Exception("解锁失败!"); 94 | } 95 | } 96 | 97 | #endregion Implementation of IDistributedLock 98 | 99 | #region Private Method 100 | 101 | private bool Store(IEnumerable tokens) 102 | { 103 | return _client.Store(StoreMode.Set, DistributedLockGroupKey, tokens.ToArray()); 104 | } 105 | 106 | private string[] GetTokens() 107 | { 108 | return _client.Get(DistributedLockGroupKey) ?? new string[0]; 109 | } 110 | 111 | #endregion Private Method 112 | } 113 | } -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Distributed.Utility")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Distributed.Utility")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("8578877a-b2c1-4321-bb11-a7ae1fecf948")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Distributed.Utility/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Distributed/Distributed.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distributed.SessionProvider.Redis", "Distributed.SessionProvider.Redis\Distributed.SessionProvider.Redis.csproj", "{F4950134-B5D7-4246-9DC7-EA89D6F18F96}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distributed.MessageQueue", "Distributed.MessageQueue\Distributed.MessageQueue.csproj", "{47D998DE-7110-4A51-A0F4-77BF8109D72A}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{36215240-EC11-4D1C-9BEA-134E37B94841}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Consumer", "Samples\MessageQueue\Consumer\Consumer.csproj", "{2618163E-940E-42ED-AD59-591270802F18}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Producer", "Samples\MessageQueue\Producer\Producer.csproj", "{7E517D77-16BC-47C2-A67F-D87103BC5F84}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MessageQueue", "MessageQueue", "{8104A8CA-3304-49A5-AFFA-3D1CA6F3DE85}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SessionShared", "SessionShared", "{76179559-57EA-4E85-B940-5761874ACA45}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "Samples\SessionShared\WebApplication2\WebApplication2.csproj", "{02A92394-F72E-47AE-8920-1C46DA1E00AB}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "Samples\SessionShared\WebApplication1\WebApplication1.csproj", "{1F900822-E434-464E-A39A-6ED24BDDB048}" 23 | EndProject 24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distributed.SessionProvider.Memcached", "Distributed.SessionProvider.Memcached\Distributed.SessionProvider.Memcached.csproj", "{E89B22B4-6CE8-4533-AC08-EA17A722545F}" 25 | EndProject 26 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distributed.Utility", "Distributed.Utility\Distributed.Utility.csproj", "{8578877A-B2C1-4321-BB11-A7AE1FECF948}" 27 | EndProject 28 | Global 29 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 30 | Debug|Any CPU = Debug|Any CPU 31 | Debug|x64 = Debug|x64 32 | Debug|x86 = Debug|x86 33 | Release|Any CPU = Release|Any CPU 34 | Release|x64 = Release|x64 35 | Release|x86 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 38 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|x64.ActiveCfg = Debug|x64 41 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|x64.Build.0 = Debug|x64 42 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|x86.ActiveCfg = Debug|x86 43 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Debug|x86.Build.0 = Debug|x86 44 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|x64.ActiveCfg = Release|x64 47 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|x64.Build.0 = Release|x64 48 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|x86.ActiveCfg = Release|x86 49 | {F4950134-B5D7-4246-9DC7-EA89D6F18F96}.Release|x86.Build.0 = Release|x86 50 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|x64.ActiveCfg = Debug|x64 53 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|x64.Build.0 = Debug|x64 54 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|x86.ActiveCfg = Debug|x86 55 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Debug|x86.Build.0 = Debug|x86 56 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|x64.ActiveCfg = Release|x64 59 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|x64.Build.0 = Release|x64 60 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|x86.ActiveCfg = Release|x86 61 | {47D998DE-7110-4A51-A0F4-77BF8109D72A}.Release|x86.Build.0 = Release|x86 62 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|x64.ActiveCfg = Debug|x64 65 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|x64.Build.0 = Debug|x64 66 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|x86.ActiveCfg = Debug|x86 67 | {2618163E-940E-42ED-AD59-591270802F18}.Debug|x86.Build.0 = Debug|x86 68 | {2618163E-940E-42ED-AD59-591270802F18}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {2618163E-940E-42ED-AD59-591270802F18}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {2618163E-940E-42ED-AD59-591270802F18}.Release|x64.ActiveCfg = Release|x64 71 | {2618163E-940E-42ED-AD59-591270802F18}.Release|x64.Build.0 = Release|x64 72 | {2618163E-940E-42ED-AD59-591270802F18}.Release|x86.ActiveCfg = Release|x86 73 | {2618163E-940E-42ED-AD59-591270802F18}.Release|x86.Build.0 = Release|x86 74 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|x64.ActiveCfg = Debug|x64 77 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|x64.Build.0 = Debug|x64 78 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|x86.ActiveCfg = Debug|x86 79 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Debug|x86.Build.0 = Debug|x86 80 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|Any CPU.ActiveCfg = Release|Any CPU 81 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|Any CPU.Build.0 = Release|Any CPU 82 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|x64.ActiveCfg = Release|x64 83 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|x64.Build.0 = Release|x64 84 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|x86.ActiveCfg = Release|x86 85 | {7E517D77-16BC-47C2-A67F-D87103BC5F84}.Release|x86.Build.0 = Release|x86 86 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 87 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|Any CPU.Build.0 = Debug|Any CPU 88 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|x64.ActiveCfg = Debug|x64 89 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|x64.Build.0 = Debug|x64 90 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|x86.ActiveCfg = Debug|x86 91 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Debug|x86.Build.0 = Debug|x86 92 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|Any CPU.ActiveCfg = Release|Any CPU 93 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|Any CPU.Build.0 = Release|Any CPU 94 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|x64.ActiveCfg = Release|x64 95 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|x64.Build.0 = Release|x64 96 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|x86.ActiveCfg = Release|x86 97 | {02A92394-F72E-47AE-8920-1C46DA1E00AB}.Release|x86.Build.0 = Release|x86 98 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 99 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|Any CPU.Build.0 = Debug|Any CPU 100 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|x64.ActiveCfg = Debug|x64 101 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|x64.Build.0 = Debug|x64 102 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|x86.ActiveCfg = Debug|x86 103 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Debug|x86.Build.0 = Debug|x86 104 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|Any CPU.ActiveCfg = Release|Any CPU 105 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|Any CPU.Build.0 = Release|Any CPU 106 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|x64.ActiveCfg = Release|x64 107 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|x64.Build.0 = Release|x64 108 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|x86.ActiveCfg = Release|x86 109 | {1F900822-E434-464E-A39A-6ED24BDDB048}.Release|x86.Build.0 = Release|x86 110 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 111 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|Any CPU.Build.0 = Debug|Any CPU 112 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|x64.ActiveCfg = Debug|Any CPU 113 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|x64.Build.0 = Debug|Any CPU 114 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|x86.ActiveCfg = Debug|Any CPU 115 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Debug|x86.Build.0 = Debug|Any CPU 116 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|Any CPU.ActiveCfg = Release|Any CPU 117 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|Any CPU.Build.0 = Release|Any CPU 118 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|x64.ActiveCfg = Release|Any CPU 119 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|x64.Build.0 = Release|Any CPU 120 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|x86.ActiveCfg = Release|Any CPU 121 | {E89B22B4-6CE8-4533-AC08-EA17A722545F}.Release|x86.Build.0 = Release|Any CPU 122 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 123 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|Any CPU.Build.0 = Debug|Any CPU 124 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|x64.ActiveCfg = Debug|Any CPU 125 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|x64.Build.0 = Debug|Any CPU 126 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|x86.ActiveCfg = Debug|Any CPU 127 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Debug|x86.Build.0 = Debug|Any CPU 128 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|Any CPU.ActiveCfg = Release|Any CPU 129 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|Any CPU.Build.0 = Release|Any CPU 130 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|x64.ActiveCfg = Release|Any CPU 131 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|x64.Build.0 = Release|Any CPU 132 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|x86.ActiveCfg = Release|Any CPU 133 | {8578877A-B2C1-4321-BB11-A7AE1FECF948}.Release|x86.Build.0 = Release|Any CPU 134 | EndGlobalSection 135 | GlobalSection(SolutionProperties) = preSolution 136 | HideSolutionNode = FALSE 137 | EndGlobalSection 138 | GlobalSection(NestedProjects) = preSolution 139 | {2618163E-940E-42ED-AD59-591270802F18} = {8104A8CA-3304-49A5-AFFA-3D1CA6F3DE85} 140 | {7E517D77-16BC-47C2-A67F-D87103BC5F84} = {8104A8CA-3304-49A5-AFFA-3D1CA6F3DE85} 141 | {8104A8CA-3304-49A5-AFFA-3D1CA6F3DE85} = {36215240-EC11-4D1C-9BEA-134E37B94841} 142 | {76179559-57EA-4E85-B940-5761874ACA45} = {36215240-EC11-4D1C-9BEA-134E37B94841} 143 | {02A92394-F72E-47AE-8920-1C46DA1E00AB} = {76179559-57EA-4E85-B940-5761874ACA45} 144 | {1F900822-E434-464E-A39A-6ED24BDDB048} = {76179559-57EA-4E85-B940-5761874ACA45} 145 | EndGlobalSection 146 | EndGlobal 147 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Consumer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Consumer/Consumer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2618163E-940E-42ED-AD59-591270802F18} 8 | Exe 9 | Properties 10 | Consumer 11 | Consumer 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | x86 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | true 37 | bin\x86\Debug\ 38 | DEBUG;TRACE 39 | full 40 | x86 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | true 44 | 45 | 46 | bin\x86\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x86 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | true 54 | 55 | 56 | true 57 | bin\x64\Debug\ 58 | DEBUG;TRACE 59 | full 60 | x64 61 | prompt 62 | MinimumRecommendedRules.ruleset 63 | 64 | 65 | bin\x64\Release\ 66 | TRACE 67 | true 68 | pdbonly 69 | x64 70 | prompt 71 | MinimumRecommendedRules.ruleset 72 | true 73 | 74 | 75 | 76 | ..\..\..\lib\MessageQueue\ons\x86\ManagedONS.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | {47d998de-7110-4a51-a0f4-77bf8109d72a} 90 | Distributed.MessageQueue 91 | 92 | 93 | 94 | 95 | copy "$(SolutionDir)lib\MessageQueue\ons\$(PlatformName)\ONSClient4CPP.dll" "$(TargetDir)" 96 | 97 | 98 | copy "$(SolutionDir)lib\MessageQueue\ons\$(PlatformName)\ManagedONS.dll" "$(TargetDir)" 99 | 100 | 107 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Consumer/Program.cs: -------------------------------------------------------------------------------- 1 | using Distributed.MessageQueue; 2 | using Distributed.MessageQueue.Providers.Aliyun; 3 | using System; 4 | 5 | namespace Consumer 6 | { 7 | internal class Program 8 | { 9 | private static void Main() 10 | { 11 | using (IMessageQueueFactory messageQueueFactory = new AliyunMessageQueueFactory(new AliyunMessageQueueFactoryOptions 12 | { 13 | AccessKey = "xxxxxxxx", 14 | SecretKey = "xxxxxxxxxx" 15 | })) 16 | { 17 | Console.WriteLine("请输入消费者Id..."); 18 | var consumerId = Console.ReadLine(); 19 | using (var consumer = messageQueueFactory.CreateConsumer(consumerId).Result) 20 | { 21 | consumer.Subscribe("ChunSun", "*", message => 22 | { 23 | Console.WriteLine($"topic:{message.Topic}"); 24 | Console.WriteLine($"key:{message.Key}"); 25 | Console.WriteLine($"msdid:{message.MessageId}"); 26 | Console.WriteLine($"body:{message.Body}"); 27 | Console.WriteLine($"tag:{message.Tag}"); 28 | Console.WriteLine($"getStartDeliverTime:{message.StartDeliverTime}"); 29 | Console.WriteLine("======================================================"); 30 | return null; 31 | }); 32 | consumer.Start().Wait(); 33 | Console.WriteLine("正在监听,按任意键退出..."); 34 | Console.ReadLine(); 35 | } 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Consumer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Consumer")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Consumer")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("2618163e-940e-42ed-ad59-591270802f18")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Producer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Producer/Producer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7E517D77-16BC-47C2-A67F-D87103BC5F84} 8 | Exe 9 | Properties 10 | Producer 11 | Producer 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | x86 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | true 37 | bin\x86\Debug\ 38 | DEBUG;TRACE 39 | full 40 | x86 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | true 44 | 45 | 46 | bin\x86\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x86 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | true 54 | 55 | 56 | true 57 | bin\x64\Debug\ 58 | DEBUG;TRACE 59 | full 60 | x64 61 | prompt 62 | MinimumRecommendedRules.ruleset 63 | 64 | 65 | bin\x64\Release\ 66 | TRACE 67 | true 68 | pdbonly 69 | x64 70 | prompt 71 | MinimumRecommendedRules.ruleset 72 | true 73 | 74 | 75 | 76 | ..\..\..\lib\MessageQueue\ons\x86\ManagedONS.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | {47d998de-7110-4a51-a0f4-77bf8109d72a} 90 | Distributed.MessageQueue 91 | 92 | 93 | 94 | 95 | copy "$(SolutionDir)lib\MessageQueue\ons\$(PlatformName)\ONSClient4CPP.dll" "$(TargetDir)" 96 | 97 | 98 | copy "$(SolutionDir)lib\MessageQueue\ons\$(PlatformName)\ManagedONS.dll" "$(TargetDir)" 99 | 100 | 107 | -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Producer/Program.cs: -------------------------------------------------------------------------------- 1 | using Distributed.MessageQueue; 2 | using Distributed.MessageQueue.Providers.Aliyun; 3 | using System; 4 | 5 | namespace Producer 6 | { 7 | internal class Program 8 | { 9 | private static void Main() 10 | { 11 | using (IMessageQueueFactory messageQueueFactory = new AliyunMessageQueueFactory(new AliyunMessageQueueFactoryOptions 12 | { 13 | AccessKey = "xxxxxxxx", 14 | SecretKey = "xxxxxxxxxx" 15 | })) 16 | { 17 | using (var producer = messageQueueFactory.CreateProducer("ChunSun").Result) 18 | { 19 | producer.Start().Wait(); 20 | while (true) 21 | { 22 | Console.WriteLine("请输入消息,输入exit退出..."); 23 | var content = Console.ReadLine(); 24 | 25 | if (string.Equals(content, "exit", StringComparison.OrdinalIgnoreCase)) 26 | { 27 | break; 28 | } 29 | 30 | var message = new AliyunMessage 31 | { 32 | Topic = "ChunSun", 33 | Body = content 34 | }; 35 | var messageId = producer.Send(message).Result; 36 | Console.WriteLine($"发送成功,MessageId:{messageId}"); 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Distributed/Samples/MessageQueue/Producer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // 有关程序集的一般信息由以下 5 | // 控制。更改这些特性值可修改 6 | // 与程序集关联的信息。 7 | [assembly: AssemblyTitle("Producer")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Producer")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | //将 ComVisible 设置为 false 将使此程序集中的类型 17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 18 | //请将此类型的 ComVisible 特性设置为 true。 19 | [assembly: ComVisible(false)] 20 | 21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 22 | [assembly: Guid("7e517d77-16bc-47c2-a67f-d87103bc5f84")] 23 | 24 | // 程序集的版本信息由下列四个值组成: 25 | // 26 | // 主版本 27 | // 次版本 28 | // 生成号 29 | // 修订号 30 | // 31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 32 | // 方法是按如下所示使用“*”: : 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Mvc; 3 | using WebApplication1.Models; 4 | 5 | namespace WebApplication1.Controllers 6 | { 7 | public class HomeController : Controller 8 | { 9 | public ActionResult Index() 10 | { 11 | var model = new SetSessionModel { Key = "CurrentTime", Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; 12 | return View(model); 13 | } 14 | 15 | [HttpPost] 16 | public ActionResult Index(SetSessionModel model) 17 | { 18 | if (!ModelState.IsValid) 19 | return View(model); 20 | 21 | Session[model.Key] = model.Value; 22 | 23 | ViewBag.Message = "Set Success"; 24 | 25 | return View(model); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | using System.Web.Routing; 5 | 6 | namespace WebApplication1 7 | { 8 | public class Global : HttpApplication 9 | { 10 | protected void Application_Start(object sender, EventArgs e) 11 | { 12 | RouteTable.Routes.MapRoute( 13 | "Default", 14 | "{controller}/{action}/{id}", 15 | new { controller = "Home", action = "Index", id = UrlParameter.Optional }); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Models/SetSessionModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WebApplication1.Models 4 | { 5 | public sealed class SetSessionModel 6 | { 7 | [Required] 8 | public string Key { get; set; } 9 | 10 | public string Value { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过下列特性集 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("WebApplication1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebApplication1")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要 19 | // 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 23 | [assembly: Guid("1f900822-e434-464e-a39a-6ed24bddb048")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订版本 31 | // 32 | // 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值, 33 | // 方法是按如下所示使用 "*": 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Mvc.Html 2 | @model WebApplication1.Models.SetSessionModel 3 | 4 | 5 | 6 | SetSession 7 | 8 | 9 | @using (Html.BeginForm()) 10 | { 11 | @Html.ValidationSummary() 12 | @ViewBag.Message 13 |
14 | @Html.LabelFor(model => model.Key): 15 |
16 |
17 | @Html.EditorFor(model => model.Key) 18 |
19 |
20 | @Html.LabelFor(model => model.Value): 21 |
22 |
23 | @Html.EditorFor(model => model.Value) 24 |
25 |
26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 31 | 32 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/WebApplication1.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {1F900822-E434-464E-A39A-6ED24BDDB048} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | WebApplication1 15 | WebApplication1 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | true 28 | full 29 | false 30 | bin\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | bin\ 39 | TRACE 40 | prompt 41 | 4 42 | 43 | 44 | 45 | ..\..\..\packages\EnyimMemcached.2.13\lib\net35\Enyim.Caching.dll 46 | True 47 | 48 | 49 | 50 | ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 51 | True 52 | 53 | 54 | 55 | 56 | 57 | 58 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 59 | True 60 | 61 | 62 | ..\..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 63 | True 64 | 65 | 66 | ..\..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 67 | True 68 | 69 | 70 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 71 | True 72 | 73 | 74 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 75 | True 76 | 77 | 78 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 79 | True 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Web.config 90 | 91 | 92 | Web.config 93 | 94 | 95 | 96 | 97 | 98 | Designer 99 | 100 | 101 | 102 | 103 | 104 | Global.asax 105 | 106 | 107 | 108 | 109 | 110 | 111 | {e89b22b4-6ce8-4533-ac08-ea17a722545f} 112 | Distributed.SessionProvider.Memcached 113 | 114 | 115 | {f4950134-b5d7-4246-9dc7-ea89d6f18f96} 116 | Distributed.SessionProvider.Redis 117 | 118 | 119 | 120 | 10.0 121 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 122 | 123 | 124 | true 125 | bin\ 126 | DEBUG;TRACE 127 | full 128 | x86 129 | prompt 130 | MinimumRecommendedRules.ruleset 131 | 132 | 133 | bin\ 134 | TRACE 135 | true 136 | pdbonly 137 | x86 138 | prompt 139 | MinimumRecommendedRules.ruleset 140 | 141 | 142 | true 143 | bin\ 144 | DEBUG;TRACE 145 | full 146 | x64 147 | prompt 148 | MinimumRecommendedRules.ruleset 149 | 150 | 151 | bin\ 152 | TRACE 153 | true 154 | pdbonly 155 | x64 156 | prompt 157 | MinimumRecommendedRules.ruleset 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | True 167 | True 168 | 17591 169 | / 170 | http://localhost:17591/ 171 | False 172 | False 173 | 174 | 175 | False 176 | 177 | 178 | 179 | 180 | 187 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace WebApplication2.Controllers 4 | { 5 | public class HomeController : Controller 6 | { 7 | public ActionResult Index(string key) 8 | { 9 | ViewBag.Value = Session[key]; 10 | return View(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication2.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Web.Mvc; 4 | using System.Web.Routing; 5 | 6 | namespace WebApplication2 7 | { 8 | public class Global : HttpApplication 9 | { 10 | protected void Application_Start(object sender, EventArgs e) 11 | { 12 | RouteTable.Routes.MapRoute( 13 | "Default", 14 | "{controller}/{action}/{id}", 15 | new { controller = "Home", action = "Index", id = UrlParameter.Optional }); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Models/GetSessionModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace WebApplication2.Models 4 | { 5 | public sealed class GetSessionModel 6 | { 7 | [Required] 8 | public string Key { get; set; } 9 | 10 | public string Value { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过下列特性集 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("WebApplication2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebApplication2")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要 19 | // 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 23 | [assembly: Guid("02a92394-f72e-47ae-8920-1c46da1e00ab")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订版本 31 | // 32 | // 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值, 33 | // 方法是按如下所示使用 "*": 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Mvc.Html 2 | 3 | 4 | 5 | GetSession 6 | 7 | 8 | @using (Html.BeginForm("Index", "Home", FormMethod.Get)) 9 | { 10 | @Html.ValidationSummary() 11 | var key = Request.QueryString["key"]; 12 | var isShowValue = key != null; 13 | if (key == null) 14 | { 15 | key = "CurrentTime"; 16 | } 17 | if (isShowValue) 18 | { 19 |
20 | SessionValue:@ViewBag.Value 21 |
22 | } 23 |
24 | Key: 25 |
26 |
27 | 28 |
29 |
30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 31 | 32 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/WebApplication2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {02A92394-F72E-47AE-8920-1C46DA1E00AB} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | WebApplication2 15 | WebApplication2 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | true 28 | full 29 | false 30 | bin\ 31 | DEBUG;TRACE 32 | prompt 33 | 4 34 | 35 | 36 | pdbonly 37 | true 38 | bin\ 39 | TRACE 40 | prompt 41 | 4 42 | 43 | 44 | 45 | ..\..\..\packages\EnyimMemcached.2.13\lib\net35\Enyim.Caching.dll 46 | True 47 | 48 | 49 | 50 | ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 51 | True 52 | 53 | 54 | 55 | 56 | 57 | 58 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll 59 | True 60 | 61 | 62 | ..\..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll 63 | True 64 | 65 | 66 | ..\..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll 67 | True 68 | 69 | 70 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll 71 | True 72 | 73 | 74 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll 75 | True 76 | 77 | 78 | ..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll 79 | True 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Web.config 90 | 91 | 92 | Web.config 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | Global.asax 103 | 104 | 105 | 106 | 107 | 108 | 109 | {e89b22b4-6ce8-4533-ac08-ea17a722545f} 110 | Distributed.SessionProvider.Memcached 111 | 112 | 113 | {f4950134-b5d7-4246-9dc7-ea89d6f18f96} 114 | Distributed.SessionProvider.Redis 115 | 116 | 117 | 118 | 10.0 119 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 120 | 121 | 122 | true 123 | bin\ 124 | DEBUG;TRACE 125 | full 126 | x86 127 | prompt 128 | MinimumRecommendedRules.ruleset 129 | 130 | 131 | bin\ 132 | TRACE 133 | true 134 | pdbonly 135 | x86 136 | prompt 137 | MinimumRecommendedRules.ruleset 138 | 139 | 140 | true 141 | bin\ 142 | DEBUG;TRACE 143 | full 144 | x64 145 | prompt 146 | MinimumRecommendedRules.ruleset 147 | 148 | 149 | bin\ 150 | TRACE 151 | true 152 | pdbonly 153 | x64 154 | prompt 155 | MinimumRecommendedRules.ruleset 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | True 165 | True 166 | 17580 167 | / 168 | http://localhost:17580/ 169 | False 170 | False 171 | 172 | 173 | False 174 | 175 | 176 | 177 | 178 | 185 | -------------------------------------------------------------------------------- /Distributed/Samples/SessionShared/WebApplication2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Distributed/lib/MessageQueue/ons/x64/ManagedONS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RabbitTeam/Distributed/9e0c2aea24debe04d3703120423401a1fb9b5e20/Distributed/lib/MessageQueue/ons/x64/ManagedONS.dll -------------------------------------------------------------------------------- /Distributed/lib/MessageQueue/ons/x64/ONSClient4CPP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RabbitTeam/Distributed/9e0c2aea24debe04d3703120423401a1fb9b5e20/Distributed/lib/MessageQueue/ons/x64/ONSClient4CPP.dll -------------------------------------------------------------------------------- /Distributed/lib/MessageQueue/ons/x86/ManagedONS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RabbitTeam/Distributed/9e0c2aea24debe04d3703120423401a1fb9b5e20/Distributed/lib/MessageQueue/ons/x86/ManagedONS.dll -------------------------------------------------------------------------------- /Distributed/lib/MessageQueue/ons/x86/ONSClient4CPP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RabbitTeam/Distributed/9e0c2aea24debe04d3703120423401a1fb9b5e20/Distributed/lib/MessageQueue/ons/x86/ONSClient4CPP.dll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 分布式解决方案 2 | 为应用程序提供分布式部署的相关支持组件。 3 | 4 | ### 现有组件: 5 | 1. Distributed.SessionProvider.Redis(基于Redis的Session共享组件) 6 | 2. Distributed.MessageQueue(一个抽象的消息队列,集成了Aliyun ONS <阿里云开放消息服务>) 7 | 3. Distributed.SessionProvider.Memcached(基于Memcached <兼容阿里云OCS>的Session共享组件) 8 | 4. Distributed.Utility(分布式相关工具,包含了一个简单的分布式锁实现) 9 | --------------------------------------------------------------------------------