├── .gitignore ├── AkkaProcessManager.Tests ├── AkkaProcessManager.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── Tests.cs └── packages.config ├── AkkaProcessManager.sln ├── AkkaProcessManager ├── AkkaProcessManager.csproj ├── App.config ├── Bank.cs ├── CreditBureau.cs ├── LoanBroker.cs ├── LoanRateQuote.cs ├── ProcessManager.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── AkkaProcessManagerConsoleApp ├── AkkaProcessManager.ConsoleApp.csproj ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── LICENSE └── README.md /.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 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | -------------------------------------------------------------------------------- /AkkaProcessManager.Tests/AkkaProcessManager.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {34599E37-E057-4A38-B237-FAD856C7DFCD} 8 | Library 9 | Properties 10 | AkkaProcessManager.Tests 11 | AkkaProcessManager.Tests 12 | v4.5.2 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\Akka.1.0.7\lib\net45\Akka.dll 35 | True 36 | 37 | 38 | ..\packages\Akka.TestKit.1.0.7\lib\net45\Akka.TestKit.dll 39 | True 40 | 41 | 42 | ..\packages\Akka.TestKit.Xunit.1.0.7\lib\net45\Akka.TestKit.Xunit.dll 43 | True 44 | 45 | 46 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 47 | True 48 | 49 | 50 | 51 | ..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 52 | True 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll 63 | True 64 | 65 | 66 | ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll 67 | True 68 | 69 | 70 | ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll 71 | True 72 | 73 | 74 | ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll 75 | True 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | {3f0879b9-cbc6-4269-bbc5-5f359de4c53d} 85 | AkkaProcessManager 86 | 87 | 88 | 89 | 90 | 91 | 92 | 99 | -------------------------------------------------------------------------------- /AkkaProcessManager.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AkkaProcessManager.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AkkaProcessManager.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("34599e37-e057-4a38-b237-fad856c7dfcd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AkkaProcessManager.Tests/Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Akka.Actor; 7 | using Akka.TestKit.Xunit; 8 | using Xunit; 9 | using Xunit.Abstractions; 10 | 11 | namespace AkkaProcessManager { 12 | public class Tests : TestKit { 13 | private readonly ITestOutputHelper _output; 14 | 15 | public Tests(ITestOutputHelper output) { 16 | _output = output; 17 | } 18 | 19 | [Fact] 20 | public void can_spin_up_processManagerDriver_actors() { 21 | 22 | var creditBureau = Sys.ActorOf(Props.Create(() => new CreditBureau()), "creditBureau"); 23 | var bank1 = Sys.ActorOf(Props.Create(() => new Bank("bank1", 2.75, 0.30)), "bank1"); 24 | var bank2 = Sys.ActorOf(Props.Create(() => new Bank("bank2", 2.73, 0.31)), "bank2"); 25 | var bank3 = Sys.ActorOf(Props.Create(() => new Bank("bank3", 2.80, 0.29)), "bank3"); 26 | var loanBroker = 27 | Sys.ActorOf( 28 | Props.Create(() => new LoanBroker(creditBureau, new List() { bank1, bank2, bank3 })), "loanBroker"); 29 | 30 | var creditBureauPath = ActorSelection(@"/user/creditBureau") 31 | .ResolveOne(TimeSpan.FromSeconds(3)) 32 | .Result.Path.ToString(); 33 | var bank1Path = ActorSelection(@"/user/bank1") 34 | .ResolveOne(TimeSpan.FromSeconds(3)) 35 | .Result.Path.ToString(); 36 | var bank2Path = ActorSelection(@"/user/bank2") 37 | .ResolveOne(TimeSpan.FromSeconds(3)) 38 | .Result.Path.ToString(); 39 | var bank3Path = ActorSelection(@"/user/bank3") 40 | .ResolveOne(TimeSpan.FromSeconds(3)) 41 | .Result.Path.ToString(); 42 | var loanBrokerPath = ActorSelection(@"/user/loanBroker") 43 | .ResolveOne(TimeSpan.FromSeconds(3)) 44 | .Result.Path.ToString(); 45 | 46 | Assert.Equal(creditBureauPath, @"akka://test/user/creditBureau"); 47 | Assert.Equal(bank1Path, @"akka://test/user/bank1"); 48 | Assert.Equal(bank2Path, @"akka://test/user/bank2"); 49 | Assert.Equal(bank3Path, @"akka://test/user/bank3"); 50 | Assert.Equal(loanBrokerPath, @"akka://test/user/loanBroker"); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /AkkaProcessManager.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /AkkaProcessManager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AkkaProcessManager", "AkkaProcessManager\AkkaProcessManager.csproj", "{3F0879B9-CBC6-4269-BBC5-5F359DE4C53D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AkkaProcessManager.ConsoleApp", "AkkaProcessManagerConsoleApp\AkkaProcessManager.ConsoleApp.csproj", "{44739E69-E8D2-4A56-AA61-566B71DEE134}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AkkaProcessManager.Tests", "AkkaProcessManager.Tests\AkkaProcessManager.Tests.csproj", "{34599E37-E057-4A38-B237-FAD856C7DFCD}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {3F0879B9-CBC6-4269-BBC5-5F359DE4C53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {3F0879B9-CBC6-4269-BBC5-5F359DE4C53D}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {3F0879B9-CBC6-4269-BBC5-5F359DE4C53D}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {3F0879B9-CBC6-4269-BBC5-5F359DE4C53D}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {44739E69-E8D2-4A56-AA61-566B71DEE134}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {44739E69-E8D2-4A56-AA61-566B71DEE134}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {44739E69-E8D2-4A56-AA61-566B71DEE134}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {44739E69-E8D2-4A56-AA61-566B71DEE134}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {34599E37-E057-4A38-B237-FAD856C7DFCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {34599E37-E057-4A38-B237-FAD856C7DFCD}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {34599E37-E057-4A38-B237-FAD856C7DFCD}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {34599E37-E057-4A38-B237-FAD856C7DFCD}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /AkkaProcessManager/AkkaProcessManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3F0879B9-CBC6-4269-BBC5-5F359DE4C53D} 8 | Library 9 | Properties 10 | AkkaProcessManager 11 | AkkaProcessManager 12 | v4.5.2 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\Akka.1.0.7\lib\net45\Akka.dll 35 | True 36 | 37 | 38 | ..\packages\Akka.Serialization.Wire.1.0.7.18-beta\lib\net45\Akka.Serialization.Wire.dll 39 | True 40 | 41 | 42 | False 43 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 44 | 45 | 46 | 47 | ..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 48 | True 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | ..\packages\Wire.0.0.6\lib\Wire.dll 59 | True 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 82 | -------------------------------------------------------------------------------- /AkkaProcessManager/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
6 | 7 | 8 | 9 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /AkkaProcessManager/Bank.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Akka.Actor; 3 | using Akka.Event; 4 | using Newtonsoft.Json; 5 | 6 | namespace AkkaProcessManager { 7 | 8 | public class QuoteLoanRate { 9 | public string LoadQuoteReferenceId { get; private set; } 10 | public string TaxId { get; private set; } 11 | public int CreditScore { get; private set; } 12 | public int Amount { get; private set; } 13 | public int TermInMonths { get; private set; } 14 | 15 | public QuoteLoanRate(string loadQuoteReferenceId, string taxId, int creditScore, int amount, int termInMonths) { 16 | LoadQuoteReferenceId = loadQuoteReferenceId; 17 | TaxId = taxId; 18 | CreditScore = creditScore; 19 | Amount = amount; 20 | TermInMonths = termInMonths; 21 | } 22 | } 23 | 24 | public class BankLoanRateQuoted { 25 | public string BankId { get; private set; } 26 | public string BankLoanRateQuoteId { get; private set; } 27 | public string LoanQuoteReferenceId { get; private set; } 28 | public string TaxId { get; private set; } 29 | public double InterestRate { get; private set; } 30 | 31 | public BankLoanRateQuoted(string bankId, string bankLoanRateQuoteId, string loanQuoteReferenceId, string taxId, double interestRate) { 32 | BankId = bankId; 33 | BankLoanRateQuoteId = bankLoanRateQuoteId; 34 | LoanQuoteReferenceId = loanQuoteReferenceId; 35 | TaxId = taxId; 36 | InterestRate = interestRate; 37 | } 38 | } 39 | 40 | public class Bank : ReceiveActor { 41 | private string _bankId; 42 | private double _primeRate; 43 | private double _ratePremium; 44 | private Random _randomQuoteId = new Random(); 45 | public Random _randomDiscount = new Random(); 46 | 47 | private readonly ILoggingAdapter _logger = Context.GetLogger(); 48 | 49 | public Bank(string bankId, double primeRate, double ratePremium) { 50 | _bankId = bankId; 51 | _primeRate = primeRate; 52 | _ratePremium = ratePremium; 53 | 54 | Receive( 55 | message => QuoteLoanRateHandler(message)); 56 | } 57 | 58 | private void QuoteLoanRateHandler(QuoteLoanRate message) { 59 | _logger.Info("Bank: {0} recieved QuoteLoanRate message:\n{1}", 60 | _bankId, 61 | JsonConvert.SerializeObject(message)); 62 | var interestRate = 63 | CalculateInterestRate( 64 | (double) message.Amount, 65 | (double) message.TermInMonths, 66 | (double) message.CreditScore); 67 | var quoted = 68 | new BankLoanRateQuoted( 69 | this._bankId, 70 | this._randomQuoteId.Next(1000).ToString(), 71 | message.LoadQuoteReferenceId, 72 | message.TaxId, 73 | interestRate); 74 | Sender.Tell(quoted); 75 | } 76 | 77 | private double CalculateInterestRate(double amount, double months, double crediScore) { 78 | var creditScoreDiscount = crediScore / 100.0 / 10.0 - (this._randomDiscount.Next(5) * 0.05); 79 | return _primeRate + _ratePremium + ((months / 12.0) / 10.0) - creditScoreDiscount; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /AkkaProcessManager/CreditBureau.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Akka.Actor; 7 | using Akka.Event; 8 | using Newtonsoft.Json; 9 | 10 | namespace AkkaProcessManager { 11 | public class CheckCredit { 12 | public string CreditProcessReferenceId { get; private set; } 13 | public string TaxId { get; private set; } 14 | 15 | public CheckCredit(string creditProcessReferenceId, string taxId) { 16 | CreditProcessReferenceId = creditProcessReferenceId; 17 | TaxId = taxId; 18 | } 19 | } 20 | 21 | public class CreditChecked { 22 | public string CreditProcessingReferenceId { get; private set; } 23 | public string TaxId { get; private set; } 24 | public int Score { get; private set; } 25 | 26 | public CreditChecked(string creditProcessingReferenceId, string taxId, int score) { 27 | CreditProcessingReferenceId = creditProcessingReferenceId; 28 | TaxId = taxId; 29 | Score = score; 30 | } 31 | } 32 | 33 | public class CreditBureau : ReceiveActor { 34 | private int[] _creditRanges = new int[] { 300, 400, 500, 600, 700 }; 35 | private Random _randomCreditRangeGenerator = new Random(); 36 | private Random _randomCreditScoreGenerator = new Random(); 37 | 38 | private readonly ILoggingAdapter _logger = Context.GetLogger(); 39 | 40 | public CreditBureau() { 41 | Receive( 42 | message => CheckCreditHandler(message)); 43 | } 44 | 45 | public void CheckCreditHandler(CheckCredit message) { 46 | _logger.Info("CreditBureau recieved CheckCredit message:\n{0}", 47 | JsonConvert.SerializeObject(message)); 48 | int range = _creditRanges[_randomCreditRangeGenerator.Next(5)]; 49 | int score = range + _randomCreditScoreGenerator.Next(20); 50 | CreditChecked crediChecked = 51 | new CreditChecked( 52 | message.CreditProcessReferenceId, 53 | message.TaxId, 54 | score); 55 | _logger.Info("CreditBureau responded with CreditChecked message: " + message); 56 | Sender.Tell(crediChecked); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /AkkaProcessManager/LoanBroker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Akka.Actor; 4 | using Akka.Event; 5 | using Newtonsoft.Json; 6 | 7 | namespace AkkaProcessManager { 8 | 9 | public class QuoteBestLoanRate { 10 | public string TaxId { get; private set; } 11 | public int Amount { get; private set; } 12 | public int TermInMonths { get; private set; } 13 | 14 | public QuoteBestLoanRate(string taxId, int amount, int termInMonths) { 15 | TaxId = taxId; 16 | Amount = amount; 17 | TermInMonths = termInMonths; 18 | } 19 | } 20 | 21 | public class BestLoanRateQuoted { 22 | public string BankId { get; private set; } 23 | public string LoanRateQuoteId { get; private set; } 24 | public string TaxId { get; private set; } 25 | public int Amount { get; private set; } 26 | public int TermInMonths { get; private set; } 27 | public int CreditScore { get; private set; } 28 | public double InterestRate { get; private set; } 29 | 30 | public BestLoanRateQuoted(string bankId, string loanRateQuoteId, string taxId, int amount, int termInMonths, int creditScore, double interestRate) { 31 | BankId = bankId; 32 | LoanRateQuoteId = loanRateQuoteId; 33 | TaxId = taxId; 34 | Amount = amount; 35 | TermInMonths = termInMonths; 36 | CreditScore = creditScore; 37 | InterestRate = interestRate; 38 | } 39 | } 40 | 41 | public class BestLoanRateDenied { 42 | public string LoanRateQuoteId { get; private set; } 43 | public string TaxId { get; private set; } 44 | public int Amount { get; private set; } 45 | public int TermInMonths { get; private set; } 46 | public int CreditScore { get; private set; } 47 | 48 | public BestLoanRateDenied(string loanRateQuoteId, string taxId, int amount, int termInMonths, int creditScore) { 49 | LoanRateQuoteId = loanRateQuoteId; 50 | TaxId = taxId; 51 | Amount = amount; 52 | TermInMonths = termInMonths; 53 | CreditScore = creditScore; 54 | } 55 | } 56 | 57 | public class LoanBroker : ProcessManager { 58 | private readonly IActorRef _creditBureau; 59 | private readonly List _banks; 60 | 61 | private readonly ILoggingAdapter _logger = Context.GetLogger(); 62 | 63 | public LoanBroker(IActorRef creditBureau, List banks) { 64 | _creditBureau = creditBureau; 65 | _banks = banks; 66 | 67 | Receive( 68 | message => BankLoanRateQuotedHandler(message)); 69 | Receive( 70 | message => CreditCheckedHandler(message)); 71 | Receive( 72 | message => CreditScoreForLoanRateQuoteDeniedHandler(message)); 73 | Receive( 74 | message => CreditScoreForLoanRateQuoteEstablishedHandler(message)); 75 | Receive( 76 | message => LoanRateBestQuoteFilledHandler(message)); 77 | Receive( 78 | message => LoanRateQuoteRecordedHandler(message)); 79 | Receive( 80 | message => LoanRateQuoteStartedHandler(message)); 81 | Receive( 82 | message => LoanRateQuoteTerminatedHandler(message)); 83 | Receive( 84 | message => ProcessStartedHandler(message)); 85 | Receive( 86 | message => ProcessStoppedHandler(message)); 87 | Receive( 88 | message => QuoteBestLoanRateHandler(message)); 89 | } 90 | 91 | private void BankLoanRateQuotedHandler(BankLoanRateQuoted message) { 92 | _logger.Info("LoanBroker received BankLoanRateQuoted message:\n{0}", 93 | JsonConvert.SerializeObject(message)); 94 | ProcessOf(message.LoanQuoteReferenceId).Tell( 95 | new RecordLoanRateQuote(message.BankId, 96 | message.BankLoanRateQuoteId, 97 | message.InterestRate)); 98 | } 99 | 100 | private void CreditCheckedHandler(CreditChecked message) { 101 | _logger.Info("LoanBroker recieved CreditChecked message:\n{0}", 102 | JsonConvert.SerializeObject(message)); 103 | ProcessOf(message.CreditProcessingReferenceId).Tell( 104 | new EstablishCreditScoreForLoanRateQuote(message.CreditProcessingReferenceId, 105 | message.TaxId, 106 | message.Score)); 107 | } 108 | 109 | private void CreditScoreForLoanRateQuoteDeniedHandler(CreditScoreForLoanRateQuoteDenied message) { 110 | _logger.Info("LoanBroker recieved CreditScoreForLoanRateQuoteDenied message:\n{0}", 111 | JsonConvert.SerializeObject(message)); 112 | ProcessOf(message.LoanRateQuoteId).Tell( 113 | new TerminateLoanRateQuote()); 114 | var denied = new BestLoanRateDenied( 115 | message.LoanRateQuoteId, 116 | message.TaxId, 117 | message.Amount, 118 | message.TermInMonths, 119 | message.Score); 120 | _logger.Info("Would be sent to original requester:\n{0}", 121 | JsonConvert.SerializeObject(denied)); 122 | } 123 | 124 | private void CreditScoreForLoanRateQuoteEstablishedHandler(CreditScoreForLoanRateQuoteEstablished message) { 125 | _logger.Info("LoanBroker recieved CreditScoreForLoanRateQuoteEstablished message:\n{0}", 126 | JsonConvert.SerializeObject(message)); 127 | foreach (var bank in _banks) { 128 | bank.Tell( 129 | new QuoteLoanRate(message.LoanRateQuoteId, 130 | message.TaxId, 131 | message.Score, 132 | message.Amount, 133 | message.TermInMonths)); 134 | } 135 | } 136 | 137 | private void LoanRateBestQuoteFilledHandler(LoanRateBestQuoteFilled message) { 138 | _logger.Info("LoanBroker recieved LoanRateBestQuoteFilled message:\n{0}", 139 | JsonConvert.SerializeObject(message)); 140 | StopProcess(message.LoanRateQuoteId); 141 | var best = new BestLoanRateQuoted( 142 | message.BestBankLoanRateQuote.BankId, 143 | message.LoanRateQuoteId, 144 | message.TaxId, 145 | message.Amount, 146 | message.TermInMonths, 147 | message.CreditScore, 148 | message.BestBankLoanRateQuote.InterestRate); 149 | _logger.Info("Would be sent to the original requester:\n{0}", 150 | JsonConvert.SerializeObject(best)); 151 | } 152 | 153 | private void LoanRateQuoteRecordedHandler(LoanRateQuoteRecorded message) { 154 | _logger.Info("LoanBroker recieved LoanRateQuoteRecorded message:\n{0}", 155 | JsonConvert.SerializeObject(message)); 156 | 157 | // Other processing 158 | } 159 | 160 | private void LoanRateQuoteStartedHandler(LoanRateQuoteStarted message) { 161 | _logger.Info("LoanBroker recieved LoanRateQuoteStarted message:\n{0}", 162 | JsonConvert.SerializeObject(message)); 163 | _creditBureau.Tell(new CheckCredit( 164 | message.LoanRateQuoteId, 165 | message.TaxId)); 166 | } 167 | 168 | private void LoanRateQuoteTerminatedHandler(LoanRateQuoteTerminated message) { 169 | _logger.Info("LoanBroker recieved LoanRateQuoteTerminated message:\n{0}", 170 | JsonConvert.SerializeObject(message)); 171 | StopProcess(message.LoanRateQuoteId); 172 | } 173 | 174 | private void ProcessStartedHandler(ProcessStarted message) { 175 | _logger.Info("LoanBroker recieved ProcessStarted message for ProcessId: {0}", message.ProcessId); 176 | message.Process.Tell(new StartLoanRateQuote(_banks.Count)); 177 | } 178 | 179 | private void ProcessStoppedHandler(ProcessStopped message) { 180 | _logger.Info("LoanBroker recieved ProcessStopped message for ProcessId: {0}", message.ProcessId); 181 | Context.Stop(message.Process); 182 | } 183 | 184 | private void QuoteBestLoanRateHandler(QuoteBestLoanRate message) { 185 | var loanRateQuoteId = Guid.NewGuid().ToString(); 186 | _logger.Info("Starting QuoteBestLoanRate:\n{0}", 187 | JsonConvert.SerializeObject(message)); 188 | IActorRef loanRateQuote = Context.ActorOf( 189 | Props.Create(() => new LoanRateQuote( 190 | loanRateQuoteId, 191 | message.TaxId, 192 | message.Amount, 193 | message.TermInMonths, 194 | Self))); 195 | StartProcess(loanRateQuoteId, loanRateQuote); 196 | } 197 | } 198 | } -------------------------------------------------------------------------------- /AkkaProcessManager/LoanRateQuote.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Xml.Schema; 3 | using Akka.Actor; 4 | using Akka.Event; 5 | using Newtonsoft.Json; 6 | 7 | namespace AkkaProcessManager { 8 | 9 | #region Messages 10 | public class StartLoanRateQuote { 11 | public int ExpectedLoanRateQuotes { get; private set; } 12 | 13 | public StartLoanRateQuote(int expectedLoanRateQuotes) { 14 | ExpectedLoanRateQuotes = expectedLoanRateQuotes; 15 | } 16 | } 17 | 18 | public class LoanRateQuoteStarted { 19 | public string LoanRateQuoteId { get; private set; } 20 | public string TaxId { get; private set; } 21 | 22 | public LoanRateQuoteStarted(string loanRateQuoteId, string taxId) { 23 | LoanRateQuoteId = loanRateQuoteId; 24 | TaxId = taxId; 25 | } 26 | } 27 | 28 | public class TerminateLoanRateQuote { 29 | } 30 | 31 | public class LoanRateQuoteTerminated { 32 | public string LoanRateQuoteId { get; private set; } 33 | public string TaxId { get; private set; } 34 | 35 | public LoanRateQuoteTerminated(string loanRateQuoteId, string taxId) { 36 | LoanRateQuoteId = loanRateQuoteId; 37 | TaxId = taxId; 38 | } 39 | } 40 | 41 | public class EstablishCreditScoreForLoanRateQuote { 42 | public string LoanRateQuoteId { get; private set; } 43 | public string TaxId { get; private set; } 44 | public int Score { get; private set; } 45 | 46 | public EstablishCreditScoreForLoanRateQuote(string loanRateQuoteId, string taxId, int score) { 47 | LoanRateQuoteId = loanRateQuoteId; 48 | TaxId = taxId; 49 | Score = score; 50 | } 51 | } 52 | 53 | public class CreditScoreForLoanRateQuoteEstablished { 54 | public string LoanRateQuoteId { get; private set; } 55 | public string TaxId { get; private set; } 56 | public int Score { get; private set; } 57 | public int Amount { get; private set; } 58 | public int TermInMonths { get; private set; } 59 | 60 | public CreditScoreForLoanRateQuoteEstablished(string loanRateQuoteId, string taxId, int score, int amount, int termInMonths) { 61 | LoanRateQuoteId = loanRateQuoteId; 62 | TaxId = taxId; 63 | Score = score; 64 | Amount = amount; 65 | TermInMonths = termInMonths; 66 | } 67 | } 68 | 69 | public class CreditScoreForLoanRateQuoteDenied { 70 | public string LoanRateQuoteId { get; private set; } 71 | public string TaxId { get; private set; } 72 | public int Score { get; private set; } 73 | public int Amount { get; private set; } 74 | public int TermInMonths { get; private set; } 75 | 76 | public CreditScoreForLoanRateQuoteDenied(string loanRateQuoteId, string taxId, int score, int amount, int termInMonths) { 77 | LoanRateQuoteId = loanRateQuoteId; 78 | TaxId = taxId; 79 | Score = score; 80 | Amount = amount; 81 | TermInMonths = termInMonths; 82 | } 83 | } 84 | 85 | public class RecordLoanRateQuote { 86 | public string BankId { get; private set; } 87 | public string BankLoanRateQuoteId { get; private set; } 88 | public double InterestRate { get; private set; } 89 | 90 | public RecordLoanRateQuote(string bankId, string bankLoanRateQuoteId, double interestRate) { 91 | BankId = bankId; 92 | BankLoanRateQuoteId = bankLoanRateQuoteId; 93 | InterestRate = interestRate; 94 | } 95 | } 96 | 97 | public class LoanRateQuoteRecorded { 98 | public string LoanRateQuoteId { get; private set; } 99 | public string TaxId { get; private set; } 100 | public BankLoanRateQuote BankLoanRateQuote { get; private set; } 101 | 102 | public LoanRateQuoteRecorded(string loanRateQuoteId, string taxId, BankLoanRateQuote bankLoanRateQuote) { 103 | LoanRateQuoteId = loanRateQuoteId; 104 | TaxId = taxId; 105 | BankLoanRateQuote = bankLoanRateQuote; 106 | } 107 | } 108 | 109 | public class LoanRateBestQuoteFilled { 110 | public string LoanRateQuoteId { get; private set; } 111 | public string TaxId { get; private set; } 112 | public int Amount { get; private set; } 113 | public int TermInMonths { get; private set; } 114 | public int CreditScore { get; private set; } 115 | public BankLoanRateQuote BestBankLoanRateQuote { get; private set; } 116 | 117 | public LoanRateBestQuoteFilled(string loanRateQuoteId, string taxId, int amount, int termInMonths, int creditScore, BankLoanRateQuote bestBankLoanRateQuote) { 118 | LoanRateQuoteId = loanRateQuoteId; 119 | TaxId = taxId; 120 | Amount = amount; 121 | TermInMonths = termInMonths; 122 | CreditScore = creditScore; 123 | BestBankLoanRateQuote = bestBankLoanRateQuote; 124 | } 125 | } 126 | 127 | public class BankLoanRateQuote { 128 | public string BankId { get; private set; } 129 | public string BankLoanRateQuoteId { get; private set; } 130 | public double InterestRate { get; private set; } 131 | 132 | public BankLoanRateQuote(string bankId, string bankLoanRateQuoteId, double interestRate) { 133 | BankId = bankId; 134 | BankLoanRateQuoteId = bankLoanRateQuoteId; 135 | InterestRate = interestRate; 136 | } 137 | } 138 | #endregion 139 | 140 | #region Actor 141 | public class LoanRateQuote : ReceiveActor { 142 | private IList _bankLoanRateQuotes = new List(); 143 | private int _creditRatingScore; 144 | private int _expectedLoanRateQuotes; 145 | 146 | private int _amount; 147 | private IActorRef _loanBroker; 148 | private string _loanRateQuoteId; 149 | private string _taxId; 150 | private int _termInMonths; 151 | 152 | private readonly ILoggingAdapter _logger = Context.GetLogger(); 153 | 154 | public LoanRateQuote(string loanRateQuoteId, string taxId, int amount, int termInMonths, IActorRef loanBroker) { 155 | this._loanRateQuoteId = loanRateQuoteId; 156 | this._taxId = taxId; 157 | this._amount = amount; 158 | this._termInMonths = termInMonths; 159 | this._loanBroker = loanBroker; 160 | 161 | Receive( 162 | message => StartLoanRateQuoteHandler(message)); 163 | Receive( 164 | message => EstablishCreditScoreForLoanRateQuoteHandler(message)); 165 | Receive( 166 | message => RecordLoanRateQuoteHandler(message)); 167 | } 168 | 169 | private void StartLoanRateQuoteHandler(StartLoanRateQuote message) { 170 | _logger.Info("LoanRateQuote received StartLonaRateQuote message:\n{0}", 171 | JsonConvert.SerializeObject(message)); 172 | _expectedLoanRateQuotes = message.ExpectedLoanRateQuotes; 173 | _loanBroker.Tell( 174 | new LoanRateQuoteStarted( 175 | _loanRateQuoteId, 176 | _taxId)); 177 | } 178 | 179 | private void EstablishCreditScoreForLoanRateQuoteHandler(EstablishCreditScoreForLoanRateQuote message) { 180 | _logger.Info("LoanRateQuote received EstablishCreditScoreForLoanRateQuote message:\n{0}", 181 | JsonConvert.SerializeObject(message)); 182 | _creditRatingScore = message.Score; 183 | if (QuotableCreditScore(_creditRatingScore)) { 184 | _loanBroker.Tell( 185 | new CreditScoreForLoanRateQuoteEstablished( 186 | _loanRateQuoteId, 187 | _taxId, 188 | _creditRatingScore, 189 | _amount, 190 | _termInMonths)); 191 | } 192 | else { 193 | _loanBroker.Tell( 194 | new CreditScoreForLoanRateQuoteDenied( 195 | _loanRateQuoteId, 196 | _taxId, 197 | _creditRatingScore, 198 | _amount, 199 | _termInMonths)); 200 | } 201 | } 202 | 203 | private void RecordLoanRateQuoteHandler(RecordLoanRateQuote message) { 204 | _logger.Info("LoanRateQuote received RecordLoanRateQuote message:\n{0}", 205 | JsonConvert.SerializeObject(message)); 206 | var bankLoanRateQuote = 207 | new BankLoanRateQuote( 208 | message.BankId, 209 | message.BankLoanRateQuoteId, 210 | message.InterestRate); 211 | _bankLoanRateQuotes.Add(bankLoanRateQuote); 212 | _loanBroker.Tell( 213 | new LoanRateQuoteRecorded( 214 | _loanRateQuoteId, 215 | _taxId, 216 | bankLoanRateQuote)); 217 | if (_bankLoanRateQuotes.Count >= _expectedLoanRateQuotes) { 218 | _loanBroker.Tell( 219 | new LoanRateBestQuoteFilled( 220 | _loanRateQuoteId, 221 | _taxId, 222 | _amount, 223 | _termInMonths, 224 | _creditRatingScore, 225 | BestBankLoanRateQuote())); 226 | } 227 | } 228 | 229 | private bool QuotableCreditScore(int score) { 230 | return score > 399; 231 | } 232 | 233 | private BankLoanRateQuote BestBankLoanRateQuote() { 234 | var best = _bankLoanRateQuotes[0]; 235 | foreach (var bankLoanRateQuote in _bankLoanRateQuotes) { 236 | if (best.InterestRate > bankLoanRateQuote.InterestRate) { 237 | best = bankLoanRateQuote; 238 | } 239 | } 240 | return best; 241 | } 242 | } 243 | #endregion 244 | } -------------------------------------------------------------------------------- /AkkaProcessManager/ProcessManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Akka.Actor; 3 | 4 | namespace AkkaProcessManager { 5 | 6 | public class ProcessStarted { 7 | public string ProcessId { get; private set; } 8 | public IActorRef Process { get; private set; } 9 | 10 | public ProcessStarted(string processId, IActorRef process) { 11 | ProcessId = processId; 12 | Process = process; 13 | } 14 | } 15 | 16 | public class ProcessStopped { 17 | public string ProcessId { get; private set; } 18 | public IActorRef Process { get; private set; } 19 | 20 | public ProcessStopped(string processId, IActorRef process) { 21 | ProcessId = processId; 22 | Process = process; 23 | } 24 | } 25 | 26 | public class ProcessManager : ReceiveActor { 27 | 28 | private readonly Dictionary _processes; 29 | 30 | public ProcessManager() { 31 | _processes = new Dictionary(); 32 | } 33 | 34 | public IActorRef ProcessOf(string processId) { 35 | if (_processes.ContainsKey(processId)) { 36 | return _processes[processId]; 37 | } 38 | return null; 39 | } 40 | 41 | public void StartProcess(string processId, IActorRef process) { 42 | if (!_processes.ContainsKey(processId)) { 43 | _processes.Add(processId, process); 44 | Self.Tell(new ProcessStarted(processId, process)); 45 | } 46 | } 47 | 48 | public void StopProcess(string processId) { 49 | if (_processes.ContainsKey("processId")) { 50 | var process = _processes[processId]; 51 | _processes.Remove(processId); 52 | Self.Tell(new ProcessStopped(processId, process)); 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /AkkaProcessManager/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AkkaProcessManager")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AkkaProcessManager")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3f0879b9-cbc6-4269-bbc5-5f359de4c53d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AkkaProcessManager/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AkkaProcessManagerConsoleApp/AkkaProcessManager.ConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {44739E69-E8D2-4A56-AA61-566B71DEE134} 8 | Exe 9 | Properties 10 | AkkaProcessManagerConsoleApp 11 | AkkaProcessManagerConsoleApp 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Akka.1.0.7\lib\net45\Akka.dll 38 | True 39 | 40 | 41 | ..\packages\Akka.Serialization.Wire.1.0.7.18-beta\lib\net45\Akka.Serialization.Wire.dll 42 | True 43 | 44 | 45 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 46 | True 47 | 48 | 49 | 50 | ..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 51 | True 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | ..\packages\Wire.0.0.6\lib\Wire.dll 62 | True 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | {3f0879b9-cbc6-4269-bbc5-5f359de4c53d} 76 | AkkaProcessManager 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /AkkaProcessManagerConsoleApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /AkkaProcessManagerConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Akka.Actor; 7 | using AkkaProcessManager; 8 | 9 | namespace AkkaProcessManagerConsoleApp { 10 | class Program { 11 | public static ActorSystem MyActorSystem; 12 | static void Main(string[] args) { 13 | Console.WriteLine("Type \"quote\" to start up to get a new loan quote"); 14 | MyActorSystem = ActorSystem.Create("MyActorSystem"); 15 | var creditBureau = MyActorSystem.ActorOf(Props.Create(() => new CreditBureau()), "creditBureau"); 16 | var bank1 = MyActorSystem.ActorOf(Props.Create(() => new Bank("bank1", 2.75, 0.30)), "bank1"); 17 | var bank2 = MyActorSystem.ActorOf(Props.Create(() => new Bank("bank2", 2.73, 0.31)), "bank2"); 18 | var bank3 = MyActorSystem.ActorOf(Props.Create(() => new Bank("bank3", 2.80, 0.29)), "bank3"); 19 | var loanBroker = 20 | MyActorSystem.ActorOf( 21 | Props.Create(() => new LoanBroker(creditBureau, new List() { bank1, bank2, bank3 })), "loanBroker"); 22 | while (true) { 23 | var entry = Console.ReadLine(); 24 | if (entry == "") { 25 | loanBroker.Tell(new QuoteBestLoanRate("111-11-111", 100000, 84)); 26 | } else if (entry == "exit") { 27 | break; 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /AkkaProcessManagerConsoleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AkkaProcessManagerConsoleApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AkkaProcessManagerConsoleApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("44739e69-e8d2-4a56-aa61-566b71dee134")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AkkaProcessManagerConsoleApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Nick Chamberlain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # akka-process-manager 2 | Blog post about building a Process Manager with Akka.NET 3 | --------------------------------------------------------------------------------