├── .dockerignore ├── .gitignore ├── PubSubDemo.DataProcessor.Bootstrapper ├── BusinessServiceExtension.cs ├── ConfigurationServiceExtension.cs ├── LogExtension.cs ├── PubSubDemo.DataProcessor.Bootstrapper.csproj ├── QueueExtension.cs └── RepositoryServiceExtension.cs ├── PubSubDemo.DataProcessor.Business.Entities ├── Acks │ └── ProductAccepted.cs ├── Events │ ├── IProductChangedMessage.cs │ ├── IProductDetailedMessage.cs │ ├── ProductChangedMessage.cs │ └── ProductDetailedMessage.cs └── PubSubDemo.DataProcessor.Business.Entities.csproj ├── PubSubDemo.DataProcessor.Business.Service.Contract ├── IProductService.cs └── PubSubDemo.DataProcessor.Business.Service.Contract.csproj ├── PubSubDemo.DataProcessor.Business.Service ├── Consumers │ └── ProductChangedConsumer.cs ├── ProductService.cs └── PubSubDemo.DataProcessor.Business.Service.csproj ├── PubSubDemo.DataProcessor.Data.Contract ├── IBaseRepository.cs ├── IDataContext.cs ├── IProductRepository.cs └── PubSubDemo.DataProcessor.Data.Contract.csproj ├── PubSubDemo.DataProcessor.Data.Entities ├── BaseEntity.cs ├── Product.cs └── PubSubDemo.DataProcessor.Data.Entities.csproj ├── PubSubDemo.DataProcessor.Data ├── BaseRepository.cs ├── DataContext.cs ├── ProductRepository.cs └── PubSubDemo.DataProcessor.Data.csproj ├── PubSubDemo.DataProcessor ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── PubSubDemo.DataProcessor.csproj ├── Worker.cs ├── appsettings.Development.json └── appsettings.json ├── PubSubDemo.EventProcessor.Bootstrapper ├── ConfigurationServiceExtension.cs ├── LogExtension.cs ├── PubSubDemo.EventProcessor.Bootstrapper.csproj ├── QueueExtension.cs └── RepositoryServiceExtension.cs ├── PubSubDemo.EventProcessor.Business.Contract ├── IProductIndexService.cs ├── IProductService.cs └── PubSubDemo.EventProcessor.Business.Contract.csproj ├── PubSubDemo.EventProcessor.Business.Entities ├── Acks │ ├── ProductSavedMessageAcceptedFromDWH.cs │ └── ProductSavedMessageAcceptedFromSearchIndex.cs └── PubSubDemo.EventProcessor.Business.Entities.csproj ├── PubSubDemo.EventProcessor.Business.Service ├── Consumers │ ├── DWHConsumer.cs │ └── ProductIndexConsumer.cs ├── ProductIndexService.cs ├── ProductService.cs └── PubSubDemo.EventProcessor.Business.Service.csproj ├── PubSubDemo.EventProcessor.Data.Contract ├── IBaseRepository.cs ├── IDataContext.cs ├── IProductRepository.cs └── PubSubDemo.EventProcessor.Data.Contract.csproj ├── PubSubDemo.EventProcessor.Data.Entity ├── BaseEntity.cs ├── Product.cs └── PubSubDemo.EventProcessor.Data.Entity.csproj ├── PubSubDemo.EventProcessor.Data ├── BaseRepository.cs ├── DataContext.cs ├── ProductRepository.cs └── PubSubDemo.EventProcessor.Data.csproj ├── PubSubDemo.EventProcessor ├── DWHWorker.cs ├── Dockerfile ├── ProductIndexWorker.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── PubSubDemo.EventProcessor.csproj ├── appsettings.Development.json └── appsettings.json ├── PubSubDemo.ProductAPI.Bootstrapper ├── BusinessServiceExtension.cs ├── ConfigurationServiceExtension.cs ├── CorsServiceExtension.cs ├── LogExtension.cs ├── Middlewares │ ├── APIResponse.cs │ ├── APIResponseMiddleware.cs │ ├── ApiError.cs │ ├── ApiException.cs │ ├── ResponseMessageEnum.cs │ ├── StringEnumExtension.cs │ └── ValidationError.cs ├── PubSubDemo.ProductAPI.Bootstrapper.csproj ├── QueueExtension.cs ├── SwaggerExtension.cs └── SwaggerServiceExtension.cs ├── PubSubDemo.ProductAPI.Business.Contract ├── IProductService.cs └── PubSubDemo.ProductAPI.Business.Contract.csproj ├── PubSubDemo.ProductAPI.Business ├── Configuration │ └── Appsettings.cs ├── ProductService.cs └── PubSubDemo.ProductAPI.Business.csproj ├── PubSubDemo.ProductAPI.Entities ├── ProductDTO.cs └── PubSubDemo.ProductAPI.Entities.csproj ├── PubSubDemo.ProductAPI ├── Controllers │ ├── BaseController.cs │ └── ProductController.cs ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── PubSubDemo.ProductAPI.csproj ├── Startup.cs ├── appsettings.Development.json └── appsettings.json ├── PubSubDemo.Utils ├── ConnectionHelper.cs ├── ConnectionStrings.cs ├── ElasticSearchSettings.cs ├── PubSubDemo.Utils.csproj └── QueueSettings.cs ├── PubSubDemo.sln └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/BusinessServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PubSubDemo.DataProcessor.Business.Service; 3 | using PubSubDemo.DataProcessor.Business.Service.Contract; 4 | using System; 5 | 6 | namespace PubSubDemo.DataProcessor.Bootstrapper 7 | { 8 | public static class BusinessServiceExtension 9 | { 10 | public static IServiceCollection RegisterBusinessServices(this IServiceCollection services) 11 | { 12 | services.AddTransient(); 13 | 14 | return services; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/ConfigurationServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | using PubSubDemo.Utils; 6 | using System; 7 | 8 | namespace PubSubDemo.DataProcessor.Bootstrapper 9 | { 10 | public static class ConfigurationServiceExtension 11 | { 12 | public static IServiceCollection RegisterConfigurationServices(this IServiceCollection service, HostBuilderContext context) 13 | { 14 | var connectionStrings = new ConnectionStrings(); 15 | var queueSettings = new QueueSettings(); 16 | 17 | context.Configuration.GetSection("ConnectionStrings").Bind(connectionStrings); 18 | context.Configuration.GetSection("QueueSettings").Bind(queueSettings); 19 | 20 | service.AddSingleton(connectionStrings); 21 | service.AddSingleton(queueSettings); 22 | 23 | return service; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/LogExtension.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using PubSubDemo.DataProcessor.Business.Service; 7 | using PubSubDemo.Utils; 8 | using RabbitMQ.Client; 9 | using Serilog; 10 | using System; 11 | 12 | namespace PubSubDemo.DataProcessor.Bootstrapper 13 | { 14 | public static class LogExtension 15 | { 16 | public static IServiceCollection RegisterLogging(this IServiceCollection services, HostBuilderContext context) 17 | { 18 | var section = context.Configuration.GetSection("Serilog"); 19 | 20 | try 21 | { 22 | Log.Logger = new LoggerConfiguration() 23 | .ReadFrom.Configuration(section) 24 | .CreateLogger(); 25 | 26 | services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog()); 27 | 28 | Log.Information("Data processor started."); 29 | } 30 | catch (Exception ex) 31 | { 32 | 33 | } 34 | 35 | return services; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/PubSubDemo.DataProcessor.Bootstrapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/QueueExtension.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using PubSubDemo.DataProcessor.Business.Service; 7 | using PubSubDemo.Utils; 8 | using RabbitMQ.Client; 9 | using System; 10 | 11 | namespace PubSubDemo.DataProcessor.Bootstrapper 12 | { 13 | public static class QueueExtension 14 | { 15 | public static IServiceCollection RegisterQueueServices(this IServiceCollection services, HostBuilderContext context) 16 | { 17 | var queueSettings = new QueueSettings(); 18 | context.Configuration.GetSection("QueueSettings").Bind(queueSettings); 19 | 20 | services.AddMassTransit(c => 21 | { 22 | c.AddConsumer(); 23 | }); 24 | 25 | services.AddSingleton(provider => Bus.Factory.CreateUsingRabbitMq(cfg => 26 | { 27 | var host = cfg.Host(queueSettings.HostName, queueSettings.VirtualHost, h => { 28 | h.Username(queueSettings.UserName); 29 | h.Password(queueSettings.Password); 30 | }); 31 | cfg.SetLoggerFactory(provider.GetService()); 32 | 33 | })); 34 | 35 | return services; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Bootstrapper/RepositoryServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PubSubDemo.DataProcessor.Data; 3 | using PubSubDemo.DataProcessor.Data.Contract; 4 | using System; 5 | 6 | namespace PubSubDemo.DataProcessor.Bootstrapper 7 | { 8 | public static class RepositoryServiceExtension 9 | { 10 | public static IServiceCollection RegisterRepositoryServices(this IServiceCollection services) 11 | { 12 | services.AddTransient(); 13 | services.AddTransient(); 14 | 15 | return services; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/Acks/ProductAccepted.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.DataProcessor.Business.Entities 4 | { 5 | public class ProductAccepted 6 | { 7 | public Guid MessageId { get; set; } 8 | 9 | public bool Accepted { get; set; } 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/Events/IProductChangedMessage.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.ProductAPI.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace PubSubDemo.DataProcessor.Business.Entities 8 | { 9 | public interface IProductChangedMessage 10 | { 11 | Guid MessageId { get; set; } 12 | ProductDTO Product { get; set; } 13 | DateTime CreationDate { get; set; } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/Events/IProductDetailedMessage.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace PubSubDemo.DataProcessor.Business.Entities 7 | { 8 | public interface IProductDetailedMessage 9 | { 10 | Guid MessageId { get; set; } 11 | Product Product { get; set; } 12 | 13 | DateTime CreationDate { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/Events/ProductChangedMessage.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.ProductAPI.Entities; 2 | using System; 3 | 4 | 5 | namespace PubSubDemo.DataProcessor.Business.Entities 6 | { 7 | public class ProductChangedMessage : IProductChangedMessage 8 | { 9 | public Guid MessageId { get; set; } 10 | public ProductDTO Product { get; set; } 11 | public DateTime CreationDate { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/Events/ProductDetailedMessage.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace PubSubDemo.DataProcessor.Business.Entities.Events 7 | { 8 | public class ProductDetailedMessage : IProductDetailedMessage 9 | { 10 | public Guid MessageId { get; set; } 11 | public Product Product { get; set; } 12 | public DateTime CreationDate { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Entities/PubSubDemo.DataProcessor.Business.Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Service.Contract/IProductService.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Business.Entities; 2 | using PubSubDemo.DataProcessor.Data.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace PubSubDemo.DataProcessor.Business.Service.Contract 9 | { 10 | public interface IProductService 11 | { 12 | Task Save(IProductChangedMessage product); 13 | 14 | Task Publish(Product product); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Service.Contract/PubSubDemo.DataProcessor.Business.Service.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Service/Consumers/ProductChangedConsumer.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Logging; 3 | using PubSubDemo.DataProcessor.Business.Entities; 4 | using System; 5 | using System.Threading.Tasks; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using PubSubDemo.DataProcessor.Business.Service.Contract; 8 | 9 | namespace PubSubDemo.DataProcessor.Business.Service 10 | { 11 | public class ProductChangedConsumer : IConsumer 12 | { 13 | private readonly IServiceProvider _serviceProvider; 14 | private readonly ILogger _logger; 15 | public ProductChangedConsumer(IServiceProvider serviceProvider, ILogger logger) 16 | { 17 | _serviceProvider = serviceProvider; 18 | _logger = logger; 19 | } 20 | public async Task Consume(ConsumeContext context) 21 | { 22 | try 23 | { 24 | var productService = _serviceProvider.GetService(); 25 | var product = await productService.Save(context.Message); 26 | 27 | await productService.Publish(product); 28 | 29 | await context.RespondAsync(new 30 | { 31 | Value = $"Received: {context.Message.MessageId}" 32 | }); 33 | } 34 | catch (Exception ex) 35 | { 36 | _logger.LogError("ProductChangedConsumerError", ex); 37 | } 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Service/ProductService.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Logging; 3 | using PubSubDemo.DataProcessor.Business.Entities; 4 | using System; 5 | using System.Threading.Tasks; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using PubSubDemo.DataProcessor.Business.Service.Contract; 8 | using PubSubDemo.DataProcessor.Data.Contract; 9 | using PubSubDemo.DataProcessor.Data.Entities; 10 | using PubSubDemo.DataProcessor.Business.Entities.Events; 11 | 12 | namespace PubSubDemo.DataProcessor.Business.Service 13 | { 14 | public class ProductService : IProductService 15 | { 16 | private readonly IServiceProvider _serviceProvider; 17 | private readonly ILogger _logger; 18 | public ProductService(IServiceProvider serviceProvider, ILogger logger) 19 | { 20 | _serviceProvider = serviceProvider; 21 | _logger = logger; 22 | } 23 | 24 | public async Task Save(IProductChangedMessage product) 25 | { 26 | var entity = new Product() 27 | { 28 | Name = product.Product.Name, 29 | Price = product.Product.Price, 30 | Quantity = product.Product.Quantity, 31 | LastModifyDate = DateTime.Now, 32 | CreationDate = DateTime.Now 33 | }; 34 | 35 | var productRepository = _serviceProvider.GetService(); 36 | await productRepository.Save(entity); 37 | 38 | return entity; 39 | } 40 | 41 | public async Task Publish(Product product) 42 | { 43 | try 44 | { 45 | var publisher = _serviceProvider.GetService(); 46 | 47 | var productSavedMessage = new ProductDetailedMessage() 48 | { 49 | MessageId = new Guid(), 50 | Product = product, 51 | CreationDate = DateTime.Now 52 | }; 53 | 54 | await publisher.Publish(productSavedMessage); 55 | } 56 | catch (Exception ex) 57 | { 58 | _logger.LogError("ProductServiceProducerError", ex); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Business.Service/PubSubDemo.DataProcessor.Business.Service.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Contract/IBaseRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | 7 | namespace PubSubDemo.DataProcessor.Data.Contract 8 | { 9 | public interface IBaseRepository where T : BaseEntity 10 | { 11 | Task GetById(int id); 12 | 13 | Task FirstOrDefault(Expression> predicate); 14 | 15 | Task Add(T entity); 16 | 17 | Task AddRange(IEnumerable entities); 18 | 19 | Task Update(T entity); 20 | 21 | Task Remove(T entity); 22 | 23 | Task> GetAll(); 24 | 25 | Task> GetWhere(Expression> predicate); 26 | 27 | Task CountAll(); 28 | 29 | Task CountWhere(Expression> predicate); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Contract/IDataContext.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace PubSubDemo.DataProcessor.Data.Contract 6 | { 7 | public interface IDataContext 8 | { 9 | void EnsureDbCreated(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Contract/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace PubSubDemo.DataProcessor.Data.Contract 6 | { 7 | public interface IProductRepository : IBaseRepository 8 | { 9 | Task Save(Product product); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Contract/PubSubDemo.DataProcessor.Data.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Entities/BaseEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace PubSubDemo.DataProcessor.Data.Entities 7 | { 8 | public class BaseEntity 9 | { 10 | [Key] 11 | public int Id { get; set; } 12 | 13 | public DateTime CreationDate { get; set; } 14 | public DateTime LastModifyDate { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Entities/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.DataProcessor.Data.Entities 4 | { 5 | public class Product : BaseEntity 6 | { 7 | public string Name { get; set; } 8 | 9 | public double Price { get; set; } 10 | 11 | public short Quantity { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data.Entities/PubSubDemo.DataProcessor.Data.Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data/BaseRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using PubSubDemo.DataProcessor.Data.Contract; 3 | using PubSubDemo.DataProcessor.Data.Entities; 4 | using PubSubDemo.Utils; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Transactions; 12 | 13 | namespace PubSubDemo.DataProcessor.Data 14 | { 15 | public class BaseRepository : IBaseRepository where T : BaseEntity 16 | { 17 | private readonly ConnectionStrings _connectionStrings; 18 | 19 | public BaseRepository(ConnectionStrings connectionStrings) 20 | { 21 | _connectionStrings = connectionStrings; 22 | } 23 | 24 | public async Task GetById(int id) 25 | { 26 | using (new TransactionScope( 27 | TransactionScopeOption.Required, 28 | new TransactionOptions 29 | { 30 | IsolationLevel = IsolationLevel.ReadUncommitted, 31 | }, TransactionScopeAsyncFlowOption.Enabled)) 32 | { 33 | using (var context = new DataContext(_connectionStrings)) 34 | { 35 | return await context.Set().FindAsync(id); 36 | } 37 | } 38 | } 39 | 40 | public Task FirstOrDefault(Expression> predicate) 41 | { 42 | using (new TransactionScope( 43 | TransactionScopeOption.Required, 44 | new TransactionOptions 45 | { 46 | IsolationLevel = IsolationLevel.ReadUncommitted, 47 | }, TransactionScopeAsyncFlowOption.Enabled)) 48 | { 49 | using (var context = new DataContext(_connectionStrings)) 50 | { 51 | return context.Set().FirstOrDefaultAsync(predicate); 52 | } 53 | } 54 | 55 | } 56 | 57 | public async Task Add(T entity) 58 | { 59 | using (var context = new DataContext(_connectionStrings)) 60 | { 61 | await context.Set().AddAsync(entity); 62 | await context.SaveChangesAsync(); 63 | } 64 | } 65 | 66 | public async Task AddRange(IEnumerable entities) 67 | { 68 | using (var context = new DataContext(_connectionStrings)) 69 | { 70 | await context.Set().AddRangeAsync(entities); 71 | await context.SaveChangesAsync(); 72 | } 73 | } 74 | 75 | public async Task Update(T entity) 76 | { 77 | using (var context = new DataContext(_connectionStrings)) 78 | { 79 | context.Set().Update(entity); 80 | await context.SaveChangesAsync(); 81 | } 82 | } 83 | 84 | public Task Remove(T entity) 85 | { 86 | using (var context = new DataContext(_connectionStrings)) 87 | { 88 | context.Set().Remove(entity); 89 | return context.SaveChangesAsync(); 90 | } 91 | 92 | } 93 | 94 | public async Task> GetAll() 95 | { 96 | using (new TransactionScope( 97 | TransactionScopeOption.Required, 98 | new TransactionOptions 99 | { 100 | IsolationLevel = IsolationLevel.ReadUncommitted, 101 | }, TransactionScopeAsyncFlowOption.Enabled)) 102 | { 103 | using (var context = new DataContext(_connectionStrings)) 104 | { 105 | return await context.Set().ToListAsync(); 106 | } 107 | } 108 | 109 | } 110 | 111 | public async Task> GetWhere(Expression> predicate) 112 | { 113 | using (new TransactionScope( 114 | TransactionScopeOption.Required, 115 | new TransactionOptions 116 | { 117 | IsolationLevel = IsolationLevel.ReadUncommitted, 118 | }, TransactionScopeAsyncFlowOption.Enabled)) 119 | { 120 | using (var context = new DataContext(_connectionStrings)) 121 | { 122 | return await context.Set().Where(predicate).ToListAsync(); 123 | } 124 | } 125 | } 126 | 127 | public Task CountAll() 128 | { 129 | using (new TransactionScope( 130 | TransactionScopeOption.Required, 131 | new TransactionOptions 132 | { 133 | IsolationLevel = IsolationLevel.ReadUncommitted, 134 | }, TransactionScopeAsyncFlowOption.Enabled)) 135 | { 136 | using (var context = new DataContext(_connectionStrings)) 137 | { 138 | return context.Set().CountAsync(); 139 | } 140 | } 141 | } 142 | 143 | public Task CountWhere(Expression> predicate) 144 | { 145 | using (new TransactionScope( 146 | TransactionScopeOption.Required, 147 | new TransactionOptions 148 | { 149 | IsolationLevel = IsolationLevel.ReadUncommitted, 150 | }, TransactionScopeAsyncFlowOption.Enabled)) 151 | { 152 | using (var context = new DataContext(_connectionStrings)) 153 | { 154 | return context.Set().CountAsync(predicate); 155 | } 156 | } 157 | } 158 | 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data/DataContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using PubSubDemo.DataProcessor.Data.Contract; 3 | using PubSubDemo.DataProcessor.Data.Entities; 4 | using PubSubDemo.Utils; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace PubSubDemo.DataProcessor.Data 10 | { 11 | public class DataContext : DbContext, IDataContext 12 | { 13 | private readonly ConnectionStrings _connectionStrings; 14 | 15 | public DataContext(ConnectionStrings connectionStrings) 16 | { 17 | _connectionStrings = connectionStrings; 18 | } 19 | 20 | public void EnsureDbCreated() 21 | { 22 | this.Database.EnsureCreated(); 23 | } 24 | 25 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 26 | { 27 | optionsBuilder.UseSqlServer(_connectionStrings.Main); 28 | } 29 | 30 | protected override void OnModelCreating(ModelBuilder modelBuilder) 31 | { 32 | base.OnModelCreating(modelBuilder); 33 | 34 | modelBuilder.Entity().HasKey(x => x.Id); 35 | } 36 | 37 | public DbSet Products { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Contract; 2 | using PubSubDemo.DataProcessor.Data.Entities; 3 | using PubSubDemo.Utils; 4 | using System; 5 | using System.Threading.Tasks; 6 | 7 | namespace PubSubDemo.DataProcessor.Data 8 | { 9 | public class ProductRepository : BaseRepository, IProductRepository 10 | { 11 | 12 | public ProductRepository(ConnectionStrings connectionSettings) : base(connectionSettings) 13 | { 14 | 15 | } 16 | 17 | public async Task Save(Product product) 18 | { 19 | await base.Add(product); 20 | return product; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor.Data/PubSubDemo.DataProcessor.Data.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base 2 | WORKDIR /app 3 | 4 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 5 | WORKDIR /src 6 | COPY ["PubSubDemo.DataProcessor/PubSubDemo.DataProcessor.csproj", "PubSubDemo.DataProcessor/"] 7 | RUN dotnet restore "PubSubDemo.DataProcessor/PubSubDemo.DataProcessor.csproj" 8 | COPY . . 9 | WORKDIR "/src/PubSubDemo.DataProcessor" 10 | RUN dotnet build "PubSubDemo.DataProcessor.csproj" -c Release -o /app/build 11 | 12 | FROM build AS publish 13 | RUN dotnet publish "PubSubDemo.DataProcessor.csproj" -c Release -o /app/publish 14 | 15 | FROM base AS final 16 | WORKDIR /app 17 | COPY --from=publish /app/publish . 18 | ENTRYPOINT ["dotnet", "PubSubDemo.DataProcessor.dll"] -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using PubSubDemo.DataProcessor.Bootstrapper; 9 | using Serilog; 10 | using Microsoft.Extensions.Hosting.WindowsServices; 11 | 12 | namespace PubSubDemo.DataProcessor 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .UseWindowsService() 24 | .ConfigureLogging(loggingBuilder => 25 | { 26 | var logger = new LoggerConfiguration() 27 | .ReadFrom.Configuration(new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()) 28 | .CreateLogger(); 29 | loggingBuilder.AddSerilog(logger, dispose: true); 30 | }) 31 | .ConfigureAppConfiguration((hostingContext, config) => { 32 | 33 | config.AddConfiguration(new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()); 34 | }) 35 | .ConfigureServices((hostContext, services) => 36 | { 37 | services.RegisterConfigurationServices(hostContext); 38 | services.RegisterBusinessServices(); 39 | services.RegisterRepositoryServices(); 40 | services.RegisterLogging(hostContext); 41 | services.RegisterQueueServices(hostContext); 42 | services.AddHostedService(); 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "PubSubDemo.DataProcessor": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "DOTNET_ENVIRONMENT": "Development" 7 | } 8 | }, 9 | "Docker": { 10 | "commandName": "Docker" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/PubSubDemo.DataProcessor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | dotnet-PubSubDemo.DataProcessor-5D965F36-C641-4BAA-A346-4ECA6C8D4790 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/Worker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MassTransit; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.Extensions.Logging; 10 | using PubSubDemo.DataProcessor.Business.Service; 11 | using PubSubDemo.DataProcessor.Data.Contract; 12 | using PubSubDemo.Utils; 13 | 14 | 15 | namespace PubSubDemo.DataProcessor 16 | { 17 | public class Worker : BackgroundService 18 | { 19 | private readonly ILogger _logger; 20 | private readonly IBusControl _busControl; 21 | private readonly IServiceProvider _serviceProvider; 22 | private readonly QueueSettings _queueSettings; 23 | public Worker(IServiceProvider serviceProvider, ILogger logger, IBusControl busControl, QueueSettings queueSettings) 24 | { 25 | _logger = logger; 26 | _busControl = busControl; 27 | _serviceProvider = serviceProvider; 28 | _queueSettings = queueSettings; 29 | } 30 | 31 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 32 | { 33 | try 34 | { 35 | var dbContextService = _serviceProvider.GetService(); 36 | dbContextService.EnsureDbCreated(); 37 | 38 | _logger.LogInformation("DataProcessor started!"); 39 | 40 | 41 | var productChangeHandler = _busControl.ConnectReceiveEndpoint(_queueSettings.QueueName, x => 42 | { 43 | x.Consumer(_serviceProvider); 44 | }); 45 | 46 | await productChangeHandler.Ready; 47 | } 48 | catch (Exception ex) 49 | { 50 | _logger.LogError("DataProcessor cannot be started.", ex); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /PubSubDemo.DataProcessor/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AppSettings": { 3 | 4 | }, 5 | "QueueSettings": { 6 | "HostName": "localhost", 7 | "VirtualHost": "/", 8 | "UserName": "guest", 9 | "Password": "guest", 10 | "QueueName": "ProductQueue" 11 | }, 12 | "ConnectionStrings": { 13 | "Main": "Server=localhost;Database=MarketPlace;Trusted_Connection=True;" 14 | 15 | 16 | }, 17 | "Serilog": { 18 | "MinimumLevel": "Information", 19 | "WriteTo": [ 20 | { 21 | "Name": "MSSqlServer", 22 | "Args": { 23 | "connectionString": "Server=localhost;Database=MarketPlace;Trusted_Connection=True;", 24 | "tableName": "ApplicationLogs", 25 | "autoCreateSqlTable": true, 26 | "columnOptionsSection": { 27 | } 28 | } 29 | } 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Bootstrapper/ConfigurationServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | using PubSubDemo.Utils; 5 | using System; 6 | 7 | namespace PubSubDemo.EventProcessor.Bootstrapper 8 | { 9 | public static class ConfigurationServiceExtension 10 | { 11 | public static IServiceCollection RegisterConfigurationServices(this IServiceCollection service, HostBuilderContext context) 12 | { 13 | var connectionStrings = new ConnectionStrings(); 14 | var elasticsearchSettings = new ElasticSearchSettings(); 15 | var queueSettings = new QueueSettings(); 16 | 17 | context.Configuration.GetSection("ConnectionStrings").Bind(connectionStrings); 18 | context.Configuration.GetSection("Elastic").Bind(elasticsearchSettings); 19 | context.Configuration.GetSection("QueueSettings").Bind(queueSettings); 20 | 21 | service.AddSingleton(elasticsearchSettings); 22 | service.AddSingleton(queueSettings); 23 | service.AddSingleton(connectionStrings); 24 | 25 | return service; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Bootstrapper/LogExtension.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using PubSubDemo.Utils; 7 | using RabbitMQ.Client; 8 | using Serilog; 9 | using System; 10 | 11 | namespace PubSubDemo.EventProcessor.Bootstrapper 12 | { 13 | public static class LogExtension 14 | { 15 | public static IServiceCollection RegisterLogging(this IServiceCollection services, HostBuilderContext context) 16 | { 17 | var section = context.Configuration.GetSection("Serilog"); 18 | 19 | try 20 | { 21 | Log.Logger = new LoggerConfiguration() 22 | .ReadFrom.Configuration(section) 23 | .CreateLogger(); 24 | 25 | services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog()); 26 | 27 | Log.Information("Data processor started."); 28 | } 29 | catch (Exception ex) 30 | { 31 | 32 | } 33 | 34 | return services; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Bootstrapper/PubSubDemo.EventProcessor.Bootstrapper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 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 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Bootstrapper/QueueExtension.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using RabbitMQ.Client; 7 | using System; 8 | using PubSubDemo.Utils; 9 | using PubSubDemo.EventProcessor.Business.Service; 10 | 11 | namespace PubSubDemo.EventProcessor.Bootstrapper 12 | { 13 | public static class QueueExtension 14 | { 15 | public static IServiceCollection RegisterQueueServices(this IServiceCollection services, HostBuilderContext context) 16 | { 17 | var queueSettings = new QueueSettings(); 18 | context.Configuration.GetSection("QueueSettings").Bind(queueSettings); 19 | 20 | services.AddMassTransit(c => 21 | { 22 | c.AddConsumer(); 23 | c.AddConsumer(); 24 | }); 25 | 26 | services.AddSingleton(provider => Bus.Factory.CreateUsingRabbitMq(cfg => 27 | { 28 | var host = cfg.Host(queueSettings.HostName, queueSettings.VirtualHost, h => { 29 | h.Username(queueSettings.UserName); 30 | h.Password(queueSettings.Password); 31 | }); 32 | cfg.SetLoggerFactory(provider.GetService()); 33 | 34 | })); 35 | return services; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Bootstrapper/RepositoryServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PubSubDemo.EventProcessor.Business.Contract; 3 | using PubSubDemo.EventProcessor.Business.Service; 4 | using PubSubDemo.EventProcessor.Data; 5 | using PubSubDemo.EventProcessor.Data.Contract; 6 | using System; 7 | 8 | namespace PubSubDemo.EventProcessor.Bootstrapper 9 | { 10 | public static class RepositoryServiceExtension 11 | { 12 | public static IServiceCollection RegisterRepositoryServices(this IServiceCollection services) 13 | { 14 | services.AddTransient(); 15 | services.AddTransient(); 16 | services.AddTransient(); 17 | services.AddTransient(); 18 | 19 | return services; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Contract/IProductIndexService.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.DataProcessor.Data.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace PubSubDemo.EventProcessor.Business.Contract 7 | { 8 | public interface IProductIndexService 9 | { 10 | Task IndexProduct(List products); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Contract/IProductService.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.EventProcessor.Data.Entity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace PubSubDemo.EventProcessor.Business.Contract 7 | { 8 | public interface IProductService 9 | { 10 | Task Save(List products); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Contract/PubSubDemo.EventProcessor.Business.Contract.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Entities/Acks/ProductSavedMessageAcceptedFromDWH.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.EventProcessor.Business.Entities 4 | { 5 | public class ProductSavedMessageAcceptedFromDWH 6 | { 7 | public Guid MessageId { get; set; } 8 | 9 | public bool Accepted { get; set; } 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Entities/Acks/ProductSavedMessageAcceptedFromSearchIndex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.EventProcessor.Business.Entities 4 | { 5 | public class ProductSavedMessageAcceptedFromSearchIndex 6 | { 7 | public Guid MessageId { get; set; } 8 | 9 | public bool Accepted { get; set; } 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Entities/PubSubDemo.EventProcessor.Business.Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Service/Consumers/DWHConsumer.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using System; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Logging; 6 | using PubSubDemo.DataProcessor.Business.Entities; 7 | using PubSubDemo.EventProcessor.Business.Entities; 8 | using PubSubDemo.EventProcessor.Business.Contract; 9 | using PubSubDemo.DataProcessor.Data.Entities; 10 | using System.Collections.Generic; 11 | 12 | namespace PubSubDemo.EventProcessor.Business.Service 13 | { 14 | public class DWHConsumer : IConsumer 15 | { 16 | private readonly IServiceProvider _serviceProvider; 17 | private readonly ILogger _logger; 18 | public DWHConsumer(IServiceProvider serviceProvider, ILogger logger) 19 | { 20 | _serviceProvider = serviceProvider; 21 | _logger = logger; 22 | } 23 | public async Task Consume(ConsumeContext context) 24 | { 25 | try 26 | { 27 | var productService = _serviceProvider.GetService(); 28 | await productService.Save(new List() { context.Message.Product }); 29 | 30 | await context.RespondAsync(new 31 | { 32 | Value = $"Received: {context.Message.MessageId}" 33 | }); 34 | } 35 | catch (Exception ex) 36 | { 37 | _logger.LogError("DWHConsumer error", ex); 38 | } 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Service/Consumers/ProductIndexConsumer.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using System; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Logging; 6 | using PubSubDemo.DataProcessor.Business.Entities; 7 | using PubSubDemo.EventProcessor.Business.Entities; 8 | using PubSubDemo.EventProcessor.Business.Contract; 9 | using System.Collections.Generic; 10 | using PubSubDemo.DataProcessor.Data.Entities; 11 | 12 | namespace PubSubDemo.EventProcessor.Business.Service 13 | { 14 | public class ProductIndexConsumer : IConsumer 15 | { 16 | private readonly IServiceProvider _serviceProvider; 17 | private readonly ILogger _logger; 18 | public ProductIndexConsumer(IServiceProvider serviceProvider, ILogger logger) 19 | { 20 | _serviceProvider = serviceProvider; 21 | _logger = logger; 22 | } 23 | public async Task Consume(ConsumeContext context) 24 | { 25 | try 26 | { 27 | var indexService = _serviceProvider.GetService(); 28 | await indexService.IndexProduct(new List() { context.Message.Product }); 29 | 30 | await context.RespondAsync(new 31 | { 32 | Value = $"Received: {context.Message.MessageId}" 33 | }); 34 | } 35 | catch (Exception ex) 36 | { 37 | _logger.LogError("ProductListConsumer error", ex); 38 | } 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Service/ProductIndexService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Nest; 3 | using PubSubDemo.DataProcessor.Data.Entities; 4 | using PubSubDemo.EventProcessor.Business.Contract; 5 | using PubSubDemo.Utils; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace PubSubDemo.EventProcessor.Business.Service 12 | { 13 | public class ProductIndexService : IProductIndexService 14 | { 15 | private readonly IServiceProvider _serviceProvider; 16 | protected readonly ElasticSearchSettings _configurationSettings; 17 | private readonly ILogger _logger; 18 | 19 | public ProductIndexService(IServiceProvider serviceProvider, ILogger logger, ElasticSearchSettings configurationSettings) 20 | { 21 | _serviceProvider = serviceProvider; 22 | _configurationSettings = configurationSettings; 23 | _logger = logger; 24 | } 25 | 26 | public async Task IndexProduct(List products) 27 | { 28 | if (products != null) 29 | { 30 | var _ElasticClient = ConnectionHelper.GetClientSingleton(_configurationSettings); 31 | 32 | List items = products; 33 | 34 | var descriptor = new BulkDescriptor(); 35 | 36 | if (items != null && items.Count > 0) 37 | for (int index = 0; index < items.Count; index++) 38 | { 39 | var indexingItem = items[index]; 40 | 41 | if (indexingItem != null) 42 | descriptor.Index(o => o.Document(indexingItem) 43 | .Routing(indexingItem.Id) 44 | .Id(indexingItem.Id) 45 | .Index(_configurationSettings.AliasName)).Refresh(Elasticsearch.Net.Refresh.True); 46 | } 47 | 48 | var response = await _ElasticClient.BulkAsync(descriptor); 49 | 50 | if (!response.IsValid || response.ItemsWithErrors.Any()) 51 | { 52 | _logger.LogError(string.Format("Error on IndexItem. isValid : {0} , errorItems : {1} {2}", response.IsValid, response.ItemsWithErrors.Count(), response.ServerError.Error)); 53 | 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Service/ProductService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PubSubDemo.EventProcessor.Business.Contract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using PubSubDemo.EventProcessor.Data.Contract; 8 | using PubSubDemo.EventProcessor.Data.Entity; 9 | using System.Linq; 10 | 11 | namespace PubSubDemo.EventProcessor.Business.Service 12 | { 13 | 14 | public class ProductService : IProductService 15 | { 16 | private readonly IServiceProvider _serviceProvider; 17 | private readonly ILogger _logger; 18 | 19 | public ProductService(IServiceProvider serviceProvider, ILogger logger) 20 | { 21 | _serviceProvider = serviceProvider; 22 | _logger = logger; 23 | } 24 | 25 | public async Task Save(List products) 26 | { 27 | var productEntities = products.Select(x => new Product() { 28 | Name = x.Name, 29 | Price = x.Price, 30 | Quantity = x.Quantity, 31 | CreationDate = x.CreationDate, 32 | LastModifyDate = x.LastModifyDate 33 | }).ToList(); 34 | 35 | var repository = _serviceProvider.GetService(); 36 | await repository.AddRange(productEntities); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Business.Service/PubSubDemo.EventProcessor.Business.Service.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Contract/IBaseRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.EventProcessor.Data.Entity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | 7 | namespace PubSubDemo.EventProcessor.Data.Contract 8 | { 9 | public interface IBaseRepository where T : BaseEntity 10 | { 11 | Task GetById(int id); 12 | 13 | Task FirstOrDefault(Expression> predicate); 14 | 15 | Task Add(T entity); 16 | 17 | Task AddRange(IEnumerable entities); 18 | 19 | Task Update(T entity); 20 | 21 | Task Remove(T entity); 22 | 23 | Task> GetAll(); 24 | 25 | Task> GetWhere(Expression> predicate); 26 | 27 | Task CountAll(); 28 | 29 | Task CountWhere(Expression> predicate); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Contract/IDataContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace PubSubDemo.EventProcessor.Data.Contract 5 | { 6 | public interface IDataContext 7 | { 8 | void EnsureDbCreated(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Contract/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.EventProcessor.Data.Entity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace PubSubDemo.EventProcessor.Data.Contract 7 | { 8 | public interface IProductRepository : IBaseRepository 9 | { 10 | Task Save(Product product); 11 | Task> Save(List products); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Contract/PubSubDemo.EventProcessor.Data.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Entity/BaseEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace PubSubDemo.EventProcessor.Data.Entity 7 | { 8 | public class BaseEntity 9 | { 10 | [Key] 11 | public int Id { get; set; } 12 | 13 | public DateTime CreationDate { get; set; } 14 | public DateTime LastModifyDate { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Entity/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.EventProcessor.Data.Entity 4 | { 5 | public class Product : BaseEntity 6 | { 7 | public string Name { get; set; } 8 | 9 | public double Price { get; set; } 10 | 11 | public short Quantity { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data.Entity/PubSubDemo.EventProcessor.Data.Entity.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data/BaseRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using PubSubDemo.EventProcessor.Data.Contract; 3 | using PubSubDemo.EventProcessor.Data.Entity; 4 | using PubSubDemo.Utils; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Transactions; 12 | 13 | namespace PubSubDemo.EventProcessor.Data 14 | { 15 | public class BaseRepository : IBaseRepository where T : BaseEntity 16 | { 17 | private readonly ConnectionStrings _connectionStrings; 18 | 19 | public BaseRepository(ConnectionStrings connectionStrings) 20 | { 21 | _connectionStrings = connectionStrings; 22 | } 23 | 24 | public async Task GetById(int id) 25 | { 26 | using (new TransactionScope( 27 | TransactionScopeOption.Required, 28 | new TransactionOptions 29 | { 30 | IsolationLevel = IsolationLevel.ReadUncommitted, 31 | }, TransactionScopeAsyncFlowOption.Enabled)) 32 | { 33 | using (var context = new DataContext(_connectionStrings)) 34 | { 35 | return await context.Set().FindAsync(id); 36 | } 37 | } 38 | } 39 | 40 | public Task FirstOrDefault(Expression> predicate) 41 | { 42 | using (new TransactionScope( 43 | TransactionScopeOption.Required, 44 | new TransactionOptions 45 | { 46 | IsolationLevel = IsolationLevel.ReadUncommitted, 47 | }, TransactionScopeAsyncFlowOption.Enabled)) 48 | { 49 | using (var context = new DataContext(_connectionStrings)) 50 | { 51 | return context.Set().FirstOrDefaultAsync(predicate); 52 | } 53 | } 54 | 55 | } 56 | 57 | public async Task Add(T entity) 58 | { 59 | using (var context = new DataContext(_connectionStrings)) 60 | { 61 | await context.Set().AddAsync(entity); 62 | await context.SaveChangesAsync(); 63 | } 64 | } 65 | 66 | public async Task AddRange(IEnumerable entities) 67 | { 68 | using (var context = new DataContext(_connectionStrings)) 69 | { 70 | await context.Set().AddRangeAsync(entities); 71 | await context.SaveChangesAsync(); 72 | } 73 | } 74 | 75 | public async Task Update(T entity) 76 | { 77 | using (var context = new DataContext(_connectionStrings)) 78 | { 79 | context.Set().Update(entity); 80 | await context.SaveChangesAsync(); 81 | } 82 | } 83 | 84 | public Task Remove(T entity) 85 | { 86 | using (var context = new DataContext(_connectionStrings)) 87 | { 88 | context.Set().Remove(entity); 89 | return context.SaveChangesAsync(); 90 | } 91 | 92 | } 93 | 94 | public async Task> GetAll() 95 | { 96 | using (new TransactionScope( 97 | TransactionScopeOption.Required, 98 | new TransactionOptions 99 | { 100 | IsolationLevel = IsolationLevel.ReadUncommitted, 101 | }, TransactionScopeAsyncFlowOption.Enabled)) 102 | { 103 | using (var context = new DataContext(_connectionStrings)) 104 | { 105 | return await context.Set().ToListAsync(); 106 | } 107 | } 108 | 109 | } 110 | 111 | public async Task> GetWhere(Expression> predicate) 112 | { 113 | using (new TransactionScope( 114 | TransactionScopeOption.Required, 115 | new TransactionOptions 116 | { 117 | IsolationLevel = IsolationLevel.ReadUncommitted, 118 | }, TransactionScopeAsyncFlowOption.Enabled)) 119 | { 120 | using (var context = new DataContext(_connectionStrings)) 121 | { 122 | return await context.Set().Where(predicate).ToListAsync(); 123 | } 124 | } 125 | } 126 | 127 | public Task CountAll() 128 | { 129 | using (new TransactionScope( 130 | TransactionScopeOption.Required, 131 | new TransactionOptions 132 | { 133 | IsolationLevel = IsolationLevel.ReadUncommitted, 134 | }, TransactionScopeAsyncFlowOption.Enabled)) 135 | { 136 | using (var context = new DataContext(_connectionStrings)) 137 | { 138 | return context.Set().CountAsync(); 139 | } 140 | } 141 | } 142 | 143 | public Task CountWhere(Expression> predicate) 144 | { 145 | using (new TransactionScope( 146 | TransactionScopeOption.Required, 147 | new TransactionOptions 148 | { 149 | IsolationLevel = IsolationLevel.ReadUncommitted, 150 | }, TransactionScopeAsyncFlowOption.Enabled)) 151 | { 152 | using (var context = new DataContext(_connectionStrings)) 153 | { 154 | return context.Set().CountAsync(predicate); 155 | } 156 | } 157 | } 158 | 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data/DataContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using PubSubDemo.EventProcessor.Data.Contract; 3 | using PubSubDemo.EventProcessor.Data.Entity; 4 | using PubSubDemo.Utils; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace PubSubDemo.EventProcessor.Data 10 | { 11 | public class DataContext : DbContext, IDataContext 12 | { 13 | private readonly ConnectionStrings _connectionStrings; 14 | 15 | public DataContext(ConnectionStrings connectionStrings) 16 | { 17 | _connectionStrings = connectionStrings; 18 | } 19 | 20 | public void EnsureDbCreated() 21 | { 22 | this.Database.EnsureCreated(); 23 | } 24 | 25 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 26 | { 27 | optionsBuilder.UseSqlServer(_connectionStrings.Main); 28 | } 29 | 30 | protected override void OnModelCreating(ModelBuilder modelBuilder) 31 | { 32 | base.OnModelCreating(modelBuilder); 33 | 34 | modelBuilder.Entity().HasKey(x => x.Id); 35 | } 36 | 37 | public DbSet Products { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.EventProcessor.Data.Contract; 2 | using PubSubDemo.EventProcessor.Data.Entity; 3 | using PubSubDemo.Utils; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace PubSubDemo.EventProcessor.Data 9 | { 10 | public class ProductRepository : BaseRepository, IProductRepository 11 | { 12 | 13 | public ProductRepository(ConnectionStrings connectionSettings) : base(connectionSettings) 14 | { 15 | 16 | } 17 | 18 | public async Task Save(Product product) 19 | { 20 | await base.Add(product); 21 | return product; 22 | } 23 | 24 | public async Task> Save(List products) 25 | { 26 | await base.AddRange(products); 27 | return products; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor.Data/PubSubDemo.EventProcessor.Data.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/DWHWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MassTransit; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using PubSubDemo.EventProcessor.Business.Service; 11 | using PubSubDemo.EventProcessor.Data.Contract; 12 | 13 | namespace PubSubDemo.EventProcessor 14 | { 15 | public class DWHWorker : BackgroundService 16 | { 17 | private readonly ILogger _logger; 18 | private readonly IBusControl _busControl; 19 | private readonly IServiceProvider _serviceProvider; 20 | 21 | public DWHWorker(IServiceProvider serviceProvider, ILogger logger, IBusControl busControl) 22 | { 23 | _logger = logger; 24 | _serviceProvider = serviceProvider; 25 | _busControl = busControl; 26 | } 27 | 28 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 29 | { 30 | try 31 | { 32 | var dbContextService = _serviceProvider.GetService(); 33 | dbContextService.EnsureDbCreated(); 34 | 35 | _logger.LogInformation("DWHConsumer started"); 36 | 37 | 38 | var hostReceiveEndpointHandler = _busControl.ConnectReceiveEndpoint("DWHProductQueue", x => 39 | { 40 | x.Consumer(_serviceProvider); 41 | }); 42 | 43 | await hostReceiveEndpointHandler.Ready; 44 | } 45 | catch (Exception ex) 46 | { 47 | _logger.LogError("DWHConsumer error", ex); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base 2 | WORKDIR /app 3 | 4 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 5 | WORKDIR /src 6 | COPY ["PubSubDemo.EventProcessor/PubSubDemo.EventProcessor.csproj", "PubSubDemo.EventProcessor/"] 7 | RUN dotnet restore "PubSubDemo.EventProcessor/PubSubDemo.EventProcessor.csproj" 8 | COPY . . 9 | WORKDIR "/src/PubSubDemo.EventProcessor" 10 | RUN dotnet build "PubSubDemo.EventProcessor.csproj" -c Release -o /app/build 11 | 12 | FROM build AS publish 13 | RUN dotnet publish "PubSubDemo.EventProcessor.csproj" -c Release -o /app/publish 14 | 15 | FROM base AS final 16 | WORKDIR /app 17 | COPY --from=publish /app/publish . 18 | ENTRYPOINT ["dotnet", "PubSubDemo.EventProcessor.dll"] -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/ProductIndexWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using MassTransit; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using PubSubDemo.EventProcessor.Business.Service; 10 | 11 | namespace PubSubDemo.EventProcessor 12 | { 13 | public class ProductIndexWorker : BackgroundService 14 | { 15 | private readonly ILogger _logger; 16 | private readonly IBusControl _busControl; 17 | private readonly IServiceProvider _serviceProvider; 18 | 19 | public ProductIndexWorker(IServiceProvider serviceProvider, IBusControl busControl, ILogger logger) 20 | { 21 | _logger = logger; 22 | _busControl = busControl; 23 | _serviceProvider = serviceProvider; 24 | } 25 | 26 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 27 | { 28 | try 29 | { 30 | var hostReceiveEndpointHandler = _busControl.ConnectReceiveEndpoint("ProductListQueue", x => 31 | { 32 | x.Consumer(_serviceProvider); 33 | }); 34 | 35 | await hostReceiveEndpointHandler.Ready; 36 | } 37 | catch (Exception ex) 38 | { 39 | _logger.LogError("DWHConsumer error", ex); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using PubSubDemo.EventProcessor.Bootstrapper; 9 | using Serilog; 10 | 11 | namespace PubSubDemo.EventProcessor 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IHostBuilder CreateHostBuilder(string[] args) => 21 | Host.CreateDefaultBuilder(args) 22 | .ConfigureLogging(loggingBuilder => 23 | { 24 | var configuration = new ConfigurationBuilder() 25 | .AddJsonFile("appsettings.json") 26 | .Build(); 27 | var logger = new LoggerConfiguration() 28 | .ReadFrom.Configuration(configuration) 29 | .CreateLogger(); 30 | loggingBuilder.AddSerilog(logger, dispose: true); 31 | }) 32 | .ConfigureServices((hostContext, services) => 33 | { 34 | services.AddHostedService(); 35 | services.AddHostedService(); 36 | services.RegisterConfigurationServices(hostContext); 37 | services.RegisterQueueServices(hostContext); 38 | services.RegisterRepositoryServices(); 39 | services.RegisterLogging(hostContext); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "PubSubDemo.EventProcessor": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "DOTNET_ENVIRONMENT": "Development" 7 | } 8 | }, 9 | "Docker": { 10 | "commandName": "Docker" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/PubSubDemo.EventProcessor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | dotnet-PubSubDemo.EventProcessor-030C6347-B618-43F2-9FAE-238DCE3B5474 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /PubSubDemo.EventProcessor/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AppSettings": { 3 | 4 | }, 5 | "QueueSettings": { 6 | "HostName": "localhost", 7 | "VirtualHost": "/", 8 | "UserName": "guest", 9 | "Password": "guest", 10 | "QueueName": "ProductQueue" 11 | }, 12 | "ConnectionStrings": { 13 | "Main": "Server=localhost;Database=MarketPlaceDWH;Trusted_Connection=True;" 14 | 15 | 16 | }, 17 | "Elastic": { 18 | 19 | "ServerUrl": "http://localhost:9200/", 20 | "InitializeIndexNamePrefix": "products", 21 | "AliasName": "products", 22 | "UseAlias": "true" 23 | }, 24 | 25 | "Serilog": { 26 | "MinimumLevel": "Information", 27 | "WriteTo": [ 28 | { 29 | "Name": "MSSqlServer", 30 | "Args": { 31 | "connectionString": "Server=localhost;Database=MarketPlaceDWH;Trusted_Connection=True;", 32 | "tableName": "ApplicationLogs", 33 | "autoCreateSqlTable": true, 34 | "columnOptionsSection": { 35 | } 36 | } 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/BusinessServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PubSubDemo.ProductAPI.Business; 3 | using PubSubDemo.ProductAPI.Business.Contract; 4 | using System; 5 | 6 | namespace PubSubDemo.ProductAPI.Bootstrapper 7 | { 8 | public static class BusinessServiceExtension 9 | { 10 | public static IServiceCollection RegisterBusinessServices(this IServiceCollection services) 11 | { 12 | services.AddTransient(); 13 | 14 | return services; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/ConfigurationServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using PubSubDemo.ProductAPI.Business; 4 | using System; 5 | 6 | namespace PubSubDemo.ProductAPI.Bootstrapper 7 | { 8 | public static class ConfigurationServiceExtension 9 | { 10 | public static IServiceCollection RegisterConfigurationServices(this IServiceCollection services, IConfiguration configuration) 11 | { 12 | var appSettingsSection = configuration.GetSection("AppSettings"); 13 | var appSettings = appSettingsSection.Get(); 14 | services.Configure(appSettingsSection); 15 | services.AddSingleton(appSettings); 16 | 17 | return services; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/CorsServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace PubSubDemo.ProductAPI.Bootstrapper 5 | { 6 | public static class CorsServiceExtension 7 | { 8 | public static IServiceCollection RegisterCorsPolicy(this IServiceCollection services) 9 | { 10 | services.AddCors(o => o.AddPolicy("DefaultPolicy", builder => 11 | { 12 | builder.AllowAnyOrigin() 13 | .AllowAnyMethod() 14 | .AllowAnyHeader(); 15 | })); 16 | 17 | return services; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/LogExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using Serilog; 5 | using System.IO; 6 | 7 | namespace PubSubDemo.ProductAPI.Bootstrapper 8 | { 9 | public static class LogExtension 10 | { 11 | public static IServiceCollection RegisterLogging(this IServiceCollection services) 12 | { 13 | var configuration = new ConfigurationBuilder() 14 | .SetBasePath(Directory.GetCurrentDirectory()) 15 | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) 16 | .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true) 17 | .Build(); 18 | 19 | try 20 | { 21 | Log.Logger = new LoggerConfiguration() 22 | .ReadFrom.Configuration(configuration) 23 | .CreateLogger(); 24 | 25 | services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog()); 26 | 27 | Log.Information("WebApi Starting..."); 28 | } 29 | catch (Exception ex) 30 | { 31 | 32 | } 33 | 34 | return services; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/APIResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using System.Collections.Generic; 8 | using Microsoft.AspNetCore.Mvc.ModelBinding; 9 | using System.Runtime.Serialization; 10 | 11 | namespace PubSubDemo.ProductAPI.Bootstrapper 12 | { 13 | [DataContract] 14 | public class APIResponse 15 | { 16 | [DataMember] 17 | public string Version { get; set; } 18 | 19 | [DataMember] 20 | public int StatusCode { get; set; } 21 | 22 | [DataMember] 23 | public string Message { get; set; } 24 | 25 | [DataMember(EmitDefaultValue = false)] 26 | public ApiError ResponseException { get; set; } 27 | 28 | [DataMember(EmitDefaultValue = false)] 29 | public object Result { get; set; } 30 | 31 | public APIResponse(int statusCode, string message = "", object result = null, ApiError apiError = null, string apiVersion = "1.0.0.0") 32 | { 33 | this.StatusCode = statusCode; 34 | this.Message = message; 35 | this.Result = result; 36 | this.ResponseException = apiError; 37 | this.Version = apiVersion; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/APIResponseMiddleware.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace PubSubDemo.ProductAPI.Bootstrapper 10 | { 11 | public class APIResponseMiddleware 12 | { 13 | private readonly RequestDelegate _next; 14 | private readonly ILogger _logger; 15 | 16 | public APIResponseMiddleware(RequestDelegate next, ILogger logger) 17 | { 18 | _logger = logger; 19 | _next = next; 20 | } 21 | 22 | public async Task Invoke(HttpContext context) 23 | { 24 | if (IsSwagger(context)) 25 | await this._next(context); 26 | else 27 | { 28 | var originalBodyStream = context.Response.Body; 29 | 30 | using (var responseBody = new MemoryStream()) 31 | { 32 | context.Response.Body = responseBody; 33 | 34 | try 35 | { 36 | await _next.Invoke(context); 37 | 38 | if (context.Response.StatusCode == (int)HttpStatusCode.OK) 39 | { 40 | var body = await FormatResponse(context.Response); 41 | await HandleSuccessRequestAsync(context, body, context.Response.StatusCode); 42 | 43 | } 44 | else 45 | { 46 | _logger.LogError("Error"); 47 | await HandleNotSuccessRequestAsync(context, context.Response.StatusCode); 48 | } 49 | } 50 | catch (System.Exception ex) 51 | { 52 | _logger.LogError(ex.Message); 53 | await HandleExceptionAsync(context, ex); 54 | } 55 | finally 56 | { 57 | responseBody.Seek(0, SeekOrigin.Begin); 58 | await responseBody.CopyToAsync(originalBodyStream); 59 | } 60 | } 61 | } 62 | 63 | } 64 | 65 | private static Task HandleExceptionAsync(HttpContext context, System.Exception exception) 66 | { 67 | ApiError apiError = null; 68 | APIResponse apiResponse = null; 69 | int code = 0; 70 | 71 | if (exception is ApiException) 72 | { 73 | var ex = exception as ApiException; 74 | apiError = new ApiError(ex.Message); 75 | apiError.ValidationErrors = ex.Errors; 76 | apiError.ReferenceErrorCode = ex.ReferenceErrorCode; 77 | apiError.ReferenceDocumentLink = ex.ReferenceDocumentLink; 78 | code = ex.StatusCode; 79 | context.Response.StatusCode = code; 80 | 81 | } 82 | else if (exception is UnauthorizedAccessException) 83 | { 84 | apiError = new ApiError("Unauthorized Access"); 85 | code = (int)HttpStatusCode.Unauthorized; 86 | context.Response.StatusCode = code; 87 | } 88 | else 89 | { 90 | #if !DEBUG 91 | var msg = "An unhandled error occurred."; 92 | string stack = null; 93 | #else 94 | var msg = exception.GetBaseException().Message; 95 | string stack = exception.StackTrace; 96 | #endif 97 | 98 | apiError = new ApiError(msg); 99 | apiError.Details = stack; 100 | code = (int)HttpStatusCode.InternalServerError; 101 | context.Response.StatusCode = code; 102 | } 103 | 104 | context.Response.ContentType = "application/json"; 105 | 106 | apiResponse = new APIResponse(code, ResponseMessageEnum.Exception.GetDescription(), null, apiError); 107 | 108 | var json = JsonConvert.SerializeObject(apiResponse); 109 | 110 | return context.Response.WriteAsync(json); 111 | } 112 | 113 | private static Task HandleNotSuccessRequestAsync(HttpContext context, int code) 114 | { 115 | 116 | context.Response.ContentType = "application/json"; 117 | 118 | ApiError apiError = null; 119 | APIResponse apiResponse = null; 120 | 121 | if (code == (int)HttpStatusCode.NotFound) 122 | apiError = new ApiError("The specified URI does not exist. Please verify and try again."); 123 | else if (code == (int)HttpStatusCode.NoContent) 124 | apiError = new ApiError("The specified URI does not contain any content."); 125 | else 126 | apiError = new ApiError("Your request cannot be processed. Please contact a support."); 127 | 128 | apiResponse = new APIResponse(code, ResponseMessageEnum.Failure.GetDescription(), null, apiError); 129 | context.Response.StatusCode = code; 130 | 131 | var json = JsonConvert.SerializeObject(apiResponse); 132 | 133 | return context.Response.WriteAsync(json); 134 | } 135 | 136 | private static Task HandleSuccessRequestAsync(HttpContext context, object body, int code) 137 | { 138 | context.Response.ContentType = "application/json"; 139 | string jsonString, bodyText = string.Empty; 140 | APIResponse apiResponse = null; 141 | 142 | 143 | if (!body.ToString().IsValidJson()) 144 | bodyText = JsonConvert.SerializeObject(body); 145 | else 146 | bodyText = body.ToString(); 147 | 148 | dynamic bodyContent = JsonConvert.DeserializeObject(bodyText); 149 | Type type; 150 | 151 | type = bodyContent?.GetType(); 152 | 153 | if (type.Equals(typeof(Newtonsoft.Json.Linq.JObject))) 154 | { 155 | apiResponse = JsonConvert.DeserializeObject(bodyText); 156 | if (apiResponse.StatusCode != code) 157 | jsonString = JsonConvert.SerializeObject(apiResponse); 158 | else if (apiResponse.Result != null) 159 | jsonString = JsonConvert.SerializeObject(apiResponse); 160 | else 161 | { 162 | apiResponse = new APIResponse(code, ResponseMessageEnum.Success.GetDescription(), bodyContent, null); 163 | jsonString = JsonConvert.SerializeObject(apiResponse); 164 | } 165 | } 166 | else 167 | { 168 | apiResponse = new APIResponse(code, ResponseMessageEnum.Success.GetDescription(), bodyContent, null); 169 | jsonString = JsonConvert.SerializeObject(apiResponse); 170 | } 171 | 172 | return context.Response.WriteAsync(jsonString); 173 | } 174 | 175 | private async Task FormatResponse(HttpResponse response) 176 | { 177 | response.Body.Seek(0, SeekOrigin.Begin); 178 | var plainBodyText = await new StreamReader(response.Body).ReadToEndAsync(); 179 | response.Body.Seek(0, SeekOrigin.Begin); 180 | 181 | return plainBodyText; 182 | } 183 | 184 | private bool IsSwagger(HttpContext context) 185 | { 186 | return context.Request.Path.StartsWithSegments("/swagger"); 187 | 188 | } 189 | 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/ApiError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using System.Collections.Generic; 8 | using Microsoft.AspNetCore.Mvc.ModelBinding; 9 | using System.Linq; 10 | 11 | namespace PubSubDemo.ProductAPI.Bootstrapper 12 | { 13 | public class ApiError 14 | { 15 | public bool IsError { get; set; } 16 | public string ExceptionMessage { get; set; } 17 | public string Details { get; set; } 18 | public string ReferenceErrorCode { get; set; } 19 | public string ReferenceDocumentLink { get; set; } 20 | public IEnumerable ValidationErrors { get; set; } 21 | 22 | public ApiError(string message) 23 | { 24 | this.ExceptionMessage = message; 25 | this.IsError = true; 26 | } 27 | 28 | public ApiError(ModelStateDictionary modelState) 29 | { 30 | this.IsError = true; 31 | if (modelState != null && modelState.Any(m => m.Value.Errors.Count > 0)) 32 | { 33 | this.ExceptionMessage = "Please correct the specified validation errors and try again."; 34 | this.ValidationErrors = modelState.Keys 35 | .SelectMany(key => modelState[key].Errors.Select(x => new ValidationError(key, x.ErrorMessage))) 36 | .ToList(); 37 | 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/ApiException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using System.Collections.Generic; 8 | 9 | namespace PubSubDemo.ProductAPI.Bootstrapper 10 | { 11 | public class ApiException : System.Exception 12 | { 13 | public int StatusCode { get; set; } 14 | 15 | public IEnumerable Errors { get; set; } 16 | 17 | public string ReferenceErrorCode { get; set; } 18 | public string ReferenceDocumentLink { get; set; } 19 | 20 | public ApiException(string message, 21 | int statusCode = 500, 22 | IEnumerable errors = null, 23 | string errorCode = "", 24 | string refLink = "") : 25 | base(message) 26 | { 27 | this.StatusCode = statusCode; 28 | this.Errors = errors; 29 | this.ReferenceErrorCode = errorCode; 30 | this.ReferenceDocumentLink = refLink; 31 | } 32 | 33 | public ApiException(System.Exception ex, int statusCode = 500) : base(ex.Message) 34 | { 35 | StatusCode = statusCode; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/ResponseMessageEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using System.Collections.Generic; 8 | using Microsoft.AspNetCore.Mvc.ModelBinding; 9 | using System.Runtime.Serialization; 10 | using System.ComponentModel; 11 | 12 | namespace PubSubDemo.ProductAPI.Bootstrapper 13 | { 14 | public enum ResponseMessageEnum 15 | { 16 | [Description("Request successful.")] 17 | Success, 18 | [Description("Request responded with exceptions.")] 19 | Exception, 20 | [Description("Request denied.")] 21 | UnAuthorized, 22 | [Description("Request responded with validation error(s).")] 23 | ValidationError, 24 | [Description("Unable to process the request.")] 25 | Failure 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/StringEnumExtension.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Globalization; 7 | using System.Text; 8 | 9 | namespace PubSubDemo.ProductAPI.Bootstrapper 10 | { 11 | public static class StringEnumExtension 12 | { 13 | public static string GetDescription(this T e) where T : IConvertible 14 | { 15 | string description = null; 16 | 17 | if (e is Enum) 18 | { 19 | Type type = e.GetType(); 20 | Array values = System.Enum.GetValues(type); 21 | 22 | foreach (int val in values) 23 | { 24 | if (val == e.ToInt32(CultureInfo.InvariantCulture)) 25 | { 26 | var memInfo = type.GetMember(type.GetEnumName(val)); 27 | var descriptionAttributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); 28 | if (descriptionAttributes.Length > 0) 29 | { 30 | description = ((DescriptionAttribute)descriptionAttributes[0]).Description; 31 | } 32 | 33 | break; 34 | } 35 | } 36 | } 37 | 38 | return description; 39 | } 40 | 41 | public static bool IsValidJson(this string text) 42 | { 43 | text = text.Trim(); 44 | if ((text.StartsWith("{") && text.EndsWith("}")) || 45 | (text.StartsWith("[") && text.EndsWith("]"))) 46 | { 47 | try 48 | { 49 | var obj = JToken.Parse(text); 50 | return true; 51 | } 52 | catch (JsonReaderException jex) 53 | { 54 | return false; 55 | } 56 | catch (Exception ex) 57 | { 58 | return false; 59 | } 60 | } 61 | else 62 | { 63 | return false; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/Middlewares/ValidationError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Newtonsoft.Json; 4 | using System.IO; 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | 8 | namespace PubSubDemo.ProductAPI.Bootstrapper 9 | { 10 | public class ValidationError 11 | { 12 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 13 | public string Field { get; } 14 | 15 | public string Message { get; } 16 | 17 | public ValidationError(string field, string message) 18 | { 19 | Field = field != string.Empty ? field : null; 20 | Message = message; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/PubSubDemo.ProductAPI.Bootstrapper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/QueueExtension.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using PubSubDemo.ProductAPI.Business; 5 | using RabbitMQ.Client; 6 | using System; 7 | 8 | namespace PubSubDemo.ProductAPI.Bootstrapper 9 | { 10 | public static class QueueExtension 11 | { 12 | public static IServiceCollection RegisterQueueServices(this IServiceCollection services, IConfiguration section) 13 | { 14 | var appSettingsSection = section.GetSection("AppSettings"); 15 | var appSettings = appSettingsSection.Get(); 16 | 17 | services.AddSingleton(provider => Bus.Factory.CreateUsingRabbitMq(cfg => 18 | { 19 | var host = cfg.Host(appSettings.QueueSettings.HostName, appSettings.QueueSettings.VirtualHost, 20 | h => { 21 | h.Username(appSettings.QueueSettings.UserName); 22 | h.Password(appSettings.QueueSettings.Password); 23 | }); 24 | 25 | cfg.ExchangeType = ExchangeType.Direct; 26 | })); 27 | 28 | services.AddSingleton(provider => provider.GetRequiredService()); 29 | services.AddSingleton(provider => provider.GetRequiredService()); 30 | services.AddSingleton(provider => provider.GetRequiredService()); 31 | 32 | return services; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/SwaggerExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | 4 | namespace PubSubDemo.ProductAPI.Bootstrapper 5 | { 6 | public static class SwaggerExtension 7 | { 8 | public static IApplicationBuilder UseSwaggerConfiguration(this IApplicationBuilder app) 9 | { 10 | app.UseSwagger(); 11 | app.UseSwaggerUI(c => 12 | { 13 | c.SwaggerEndpoint("/swagger/v1/swagger.json", "Product API V1"); 14 | }); 15 | 16 | return app; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Bootstrapper/SwaggerServiceExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.OpenApi.Models; 3 | 4 | 5 | namespace PubSubDemo.ProductAPI.Bootstrapper 6 | { 7 | public static class SwaggerServiceExtension 8 | { 9 | public static IServiceCollection RegisterSwager(this IServiceCollection services) 10 | { 11 | services.AddSwaggerGen(c => 12 | { 13 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "Product API", Version = "v1" }); 14 | }); 15 | 16 | return services; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Business.Contract/IProductService.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.ProductAPI.Entities; 2 | using System; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace PubSubDemo.ProductAPI.Business.Contract 7 | { 8 | public interface IProductService 9 | { 10 | Task Put(ProductDTO request, CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Business.Contract/PubSubDemo.ProductAPI.Business.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Business/Configuration/Appsettings.cs: -------------------------------------------------------------------------------- 1 | using PubSubDemo.Utils; 2 | using System; 3 | 4 | namespace PubSubDemo.ProductAPI.Business 5 | { 6 | public class Appsettings 7 | { 8 | public QueueSettings QueueSettings { get; set; } 9 | 10 | public Appsettings() 11 | { 12 | 13 | } 14 | 15 | public Appsettings( QueueSettings queueSettings) 16 | { 17 | QueueSettings = queueSettings; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Business/ProductService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MassTransit; 3 | using Microsoft.Extensions.Logging; 4 | using System.Linq; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using MassTransit.Logging; 8 | using PubSubDemo.ProductAPI.Entities; 9 | using PubSubDemo.ProductAPI.Business.Contract; 10 | using PubSubDemo.DataProcessor.Business.Entities; 11 | 12 | namespace PubSubDemo.ProductAPI.Business 13 | { 14 | public class ProductService : IProductService 15 | { 16 | private readonly ILogger _logger; 17 | private readonly IPublishEndpoint _endpoint; 18 | private readonly Appsettings _appsettings; 19 | 20 | 21 | public ProductService(ILogger logger, IPublishEndpoint endpoint, Appsettings appsettings) 22 | { 23 | _logger = logger; 24 | _endpoint = endpoint; 25 | _appsettings = appsettings; 26 | } 27 | 28 | public async Task Put(ProductDTO request, CancellationToken cancellationToken) 29 | { 30 | try 31 | { 32 | await _endpoint.Publish(new ProductChangedMessage() 33 | { 34 | MessageId = new Guid(), 35 | Product = request, 36 | CreationDate = DateTime.Now 37 | 38 | }, cancellationToken); 39 | } 40 | catch (Exception ex) 41 | { 42 | _logger.LogError(ex.Message); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Business/PubSubDemo.ProductAPI.Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Entities/ProductDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.ProductAPI.Entities 4 | { 5 | public class ProductDTO 6 | { 7 | public string Name{ get; set; } 8 | 9 | public double Price { get; set; } 10 | 11 | public short Quantity { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI.Entities/PubSubDemo.ProductAPI.Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Controllers/BaseController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace PubSubDemo.ProductAPI.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class BaseController : ControllerBase 13 | { 14 | public readonly ILogger _logger; 15 | 16 | public readonly IServiceProvider _serviceProvider; 17 | 18 | public BaseController(ILogger logger, IServiceProvider serviceProvider) 19 | { 20 | _logger = logger; 21 | _serviceProvider = serviceProvider; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using PubSubDemo.ProductAPI.Entities; 10 | using PubSubDemo.ProductAPI.Business.Contract; 11 | 12 | namespace PubSubDemo.ProductAPI.Controllers 13 | { 14 | [Route("product")] 15 | public class ProductController : BaseController 16 | { 17 | public ProductController(ILogger logger, IServiceProvider serviceProvider) : base(logger, serviceProvider) 18 | { } 19 | 20 | [HttpPut] 21 | public async Task Put(ProductDTO product, CancellationToken cancellationToken) 22 | { 23 | var productService = _serviceProvider.GetService(); 24 | await productService.Put(product, cancellationToken); 25 | 26 | return Ok(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base 2 | WORKDIR /app 3 | EXPOSE 80 4 | EXPOSE 443 5 | 6 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build 7 | WORKDIR /src 8 | COPY ["PubSubDemo.ProductAPI/PubSubDemo.ProductAPI.csproj", "PubSubDemo.ProductAPI/"] 9 | RUN dotnet restore "PubSubDemo.ProductAPI/PubSubDemo.ProductAPI.csproj" 10 | COPY . . 11 | WORKDIR "/src/PubSubDemo.ProductAPI" 12 | RUN dotnet build "PubSubDemo.ProductAPI.csproj" -c Release -o /app/build 13 | 14 | FROM build AS publish 15 | RUN dotnet publish "PubSubDemo.ProductAPI.csproj" -c Release -o /app/publish 16 | 17 | FROM base AS final 18 | WORKDIR /app 19 | COPY --from=publish /app/publish . 20 | ENTRYPOINT ["dotnet", "PubSubDemo.ProductAPI.dll"] -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using Serilog; 10 | 11 | namespace PubSubDemo.ProductAPI 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IHostBuilder CreateHostBuilder(string[] args) => 21 | Host.CreateDefaultBuilder(args) 22 | .ConfigureWebHostDefaults(webBuilder => 23 | { 24 | webBuilder.UseStartup(); 25 | webBuilder.UseSerilog(); 26 | }); 27 | } 28 | } -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:51794", 7 | "sslPort": 44361 8 | } 9 | }, 10 | "$schema": "http://json.schemastore.org/launchsettings.json", 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "PubSubDemo.ProductAPI": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "swagger", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | }, 27 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 28 | }, 29 | "Docker": { 30 | "commandName": "Docker", 31 | "launchBrowser": true, 32 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", 33 | "environmentVariables": { 34 | "ASPNETCORE_URLS": "https://+:443;http://+:80", 35 | "ASPNETCORE_HTTPS_PORT": "44362" 36 | }, 37 | "httpPort": 51799, 38 | "useSSL": true, 39 | "sslPort": 44362 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/PubSubDemo.ProductAPI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | 2f095a44-9eb8-46c1-973d-ab713229c56a 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Hosting; 12 | using Microsoft.Extensions.Logging; 13 | using PubSubDemo.ProductAPI.Bootstrapper; 14 | using Serilog; 15 | 16 | namespace PubSubDemo.ProductAPI 17 | { 18 | public class Startup 19 | { 20 | public Startup(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | } 24 | 25 | public IConfiguration Configuration { get; } 26 | 27 | // This method gets called by the runtime. Use this method to add services to the container. 28 | public void ConfigureServices(IServiceCollection services) 29 | { 30 | services.RegisterSwager(); 31 | services.AddMvc(); 32 | services.AddControllers(); 33 | services.RegisterCorsPolicy(); 34 | services.RegisterConfigurationServices(Configuration); 35 | services.RegisterQueueServices(Configuration); 36 | services.RegisterBusinessServices(); 37 | services.RegisterLogging(); 38 | } 39 | 40 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 41 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) 42 | { 43 | if (env.IsDevelopment()) 44 | { 45 | app.UseDeveloperExceptionPage(); 46 | } 47 | 48 | app.UseCors("DefaultPolicy"); 49 | app.UseHttpsRedirection(); 50 | app.UseRouting(); 51 | app.UseSwaggerConfiguration(); 52 | app.UseAuthorization(); 53 | loggerFactory.AddSerilog(); 54 | app.UseMiddleware(typeof(APIResponseMiddleware)); 55 | 56 | app.UseEndpoints(endpoints => 57 | { 58 | endpoints.MapControllers(); 59 | }); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /PubSubDemo.ProductAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AppSettings": { 3 | "WorkItemCount": 100, 4 | 5 | "QueueSettings": { 6 | "HostName": "localhost", 7 | "VirtualHost": "/", 8 | "UserName": "guest", 9 | "Password": "guest" 10 | } 11 | }, 12 | "Serilog": { 13 | "MinimumLevel": "Information", 14 | "WriteTo": [ 15 | { 16 | "Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;": null, 17 | "Name": "MSSqlServer", 18 | "Args": { 19 | "connectionString": "Data Source=localhost;Trusted_Connection=True;Initial Catalog=Product;MultipleActiveResultSets=true", 20 | "tableName": "ProductErrorLogs", 21 | "autoCreateSqlTable": true, 22 | "columnOptionsSection": { 23 | } 24 | } 25 | } 26 | ] 27 | }, 28 | "AllowedHosts": "*", 29 | "ConnectionStrings": { 30 | "SqlConnectionStringMain": "Data Source=localhost;Trusted_Connection=True;Initial Catalog=Product;MultipleActiveResultSets=true" 31 | } 32 | } -------------------------------------------------------------------------------- /PubSubDemo.Utils/ConnectionHelper.cs: -------------------------------------------------------------------------------- 1 | using Nest; 2 | using System; 3 | 4 | namespace PubSubDemo.Utils 5 | { 6 | public class ConnectionHelper 7 | { 8 | public static ElasticClient _client; 9 | 10 | public static ElasticClient GetClientSingleton(ElasticSearchSettings setting) 11 | { 12 | if (_client != null) 13 | return _client; 14 | 15 | Uri node = new Uri(setting.ServerUrl); 16 | ConnectionSettings settings = new ConnectionSettings(node) 17 | .EnableHttpCompression(); 18 | 19 | settings.DisableDirectStreaming(); 20 | //settings.DefaultIndex(indexName); 21 | ElasticClient client = new ElasticClient(settings); 22 | 23 | return client; 24 | } 25 | 26 | public static ElasticClient GetClient(ConnectionSettings settings) 27 | { 28 | return new ElasticClient(settings); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PubSubDemo.Utils/ConnectionStrings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.Utils 4 | { 5 | public class ConnectionStrings 6 | { 7 | public string Main { get; set; } 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /PubSubDemo.Utils/ElasticSearchSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.Utils 4 | { 5 | public class ElasticSearchSettings 6 | { 7 | public string ServerUrl { get; set; } 8 | public string ProtectedWordsPath { get; set; } 9 | public string InitializeIndexNamePrefix { get; set; } 10 | public string AliasName { get; set; } 11 | public string UseAlias { get; set; } 12 | public string DatabaseName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /PubSubDemo.Utils/PubSubDemo.Utils.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PubSubDemo.Utils/QueueSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PubSubDemo.Utils 4 | { 5 | public class QueueSettings 6 | { 7 | public string HostName { get; set; } 8 | public string VirtualHost { get; set; } 9 | public string UserName { get; set; } 10 | public string Password { get; set; } 11 | public string QueueName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PubSubDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29509.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.ProductAPI", "PubSubDemo.ProductAPI\PubSubDemo.ProductAPI.csproj", "{30E51278-0B54-4186-8CBC-DB75C3B9AD4C}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.ProductAPI.Entities", "PubSubDemo.ProductAPI.Entities\PubSubDemo.ProductAPI.Entities.csproj", "{A60372F8-9F36-4F4C-B752-9351E004E8A7}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.ProductAPI.Bootstrapper", "PubSubDemo.ProductAPI.Bootstrapper\PubSubDemo.ProductAPI.Bootstrapper.csproj", "{C8114227-E594-48D4-B798-BCFE47513F0E}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{6D05E481-BEC3-436A-8772-7750E27ED35F}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.ProductAPI.Business", "PubSubDemo.ProductAPI.Business\PubSubDemo.ProductAPI.Business.csproj", "{BF41B1FF-EC8F-4362-830C-0D48CA7046C7}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.ProductAPI.Business.Contract", "PubSubDemo.ProductAPI.Business.Contract\PubSubDemo.ProductAPI.Business.Contract.csproj", "{4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataProcessor", "DataProcessor", "{8F0830DA-CD72-47A3-A775-D2F672CF6892}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Business.Entities", "PubSubDemo.DataProcessor.Business.Entities\PubSubDemo.DataProcessor.Business.Entities.csproj", "{58364AAE-F852-4F64-ABD8-45ECB683B3F1}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Business.Service", "PubSubDemo.DataProcessor.Business.Service\PubSubDemo.DataProcessor.Business.Service.csproj", "{7E57ABC3-40E2-4423-8C1E-0664E7296D8B}" 23 | EndProject 24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Business.Service.Contract", "PubSubDemo.DataProcessor.Business.Service.Contract\PubSubDemo.DataProcessor.Business.Service.Contract.csproj", "{58517299-ED91-40D3-8D30-08135268FDFE}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor", "PubSubDemo.DataProcessor\PubSubDemo.DataProcessor.csproj", "{A459C86D-D0DD-4CAE-AFEE-21103F91D7A2}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Bootstrapper", "PubSubDemo.DataProcessor.Bootstrapper\PubSubDemo.DataProcessor.Bootstrapper.csproj", "{C20D0E2D-3708-4432-8FC1-BC25AAA9BB66}" 29 | EndProject 30 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.Utils", "PubSubDemo.Utils\PubSubDemo.Utils.csproj", "{2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0}" 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Data", "PubSubDemo.DataProcessor.Data\PubSubDemo.DataProcessor.Data.csproj", "{7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1}" 33 | EndProject 34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Data.Contract", "PubSubDemo.DataProcessor.Data.Contract\PubSubDemo.DataProcessor.Data.Contract.csproj", "{760DC19C-0613-4816-8642-C125FB11E3CF}" 35 | EndProject 36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.DataProcessor.Data.Entities", "PubSubDemo.DataProcessor.Data.Entities\PubSubDemo.DataProcessor.Data.Entities.csproj", "{3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585}" 37 | EndProject 38 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventProcessor", "EventProcessor", "{A60C031B-F32B-4518-A292-184C06182A65}" 39 | EndProject 40 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{A0B17314-4E7C-4D4C-BD6F-9AA9271F06D8}" 41 | EndProject 42 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.EventProcessor.Business.Service", "PubSubDemo.EventProcessor.Business.Service\PubSubDemo.EventProcessor.Business.Service.csproj", "{1E48C083-7544-4884-A13F-49787A031959}" 43 | EndProject 44 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.EventProcessor.Business.Contract", "PubSubDemo.EventProcessor.Business.Contract\PubSubDemo.EventProcessor.Business.Contract.csproj", "{89A9F824-BA1E-4841-983C-22F97FEBBA13}" 45 | EndProject 46 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.EventProcessor", "PubSubDemo.EventProcessor\PubSubDemo.EventProcessor.csproj", "{9AE50016-502E-4E3A-B6A2-A408836C8CBC}" 47 | EndProject 48 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.EventProcessor.Bootstrapper", "PubSubDemo.EventProcessor.Bootstrapper\PubSubDemo.EventProcessor.Bootstrapper.csproj", "{7A4D13F3-B03B-4FD6-B756-C0342874C78C}" 49 | EndProject 50 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{8677A733-C74C-4B6D-A4E4-7608997CC35A}" 51 | EndProject 52 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{E2BDE344-F699-4641-8177-D61643FF0E77}" 53 | EndProject 54 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PubSubDemo.EventProcessor.Business.Entities", "PubSubDemo.EventProcessor.Business.Entities\PubSubDemo.EventProcessor.Business.Entities.csproj", "{2A396F40-9A86-473F-A3E6-54A09F716E61}" 55 | EndProject 56 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{92CD5C69-0F1F-4573-BFF2-F3F63A2887A6}" 57 | EndProject 58 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{F5282FE9-C4AB-4D87-9BEA-1C0B0F468D07}" 59 | EndProject 60 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PubSubDemo.EventProcessor.Data", "PubSubDemo.EventProcessor.Data\PubSubDemo.EventProcessor.Data.csproj", "{6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C}" 61 | EndProject 62 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PubSubDemo.EventProcessor.Data.Contract", "PubSubDemo.EventProcessor.Data.Contract\PubSubDemo.EventProcessor.Data.Contract.csproj", "{2F5CFC18-647D-44C7-9384-A703C228F3EA}" 63 | EndProject 64 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PubSubDemo.EventProcessor.Data.Entity", "PubSubDemo.EventProcessor.Data.Entity\PubSubDemo.EventProcessor.Data.Entity.csproj", "{28177887-5DBC-4AE9-9857-3277B9B17C0F}" 65 | EndProject 66 | Global 67 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 68 | Debug|Any CPU = Debug|Any CPU 69 | Release|Any CPU = Release|Any CPU 70 | EndGlobalSection 71 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 72 | {30E51278-0B54-4186-8CBC-DB75C3B9AD4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {30E51278-0B54-4186-8CBC-DB75C3B9AD4C}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {30E51278-0B54-4186-8CBC-DB75C3B9AD4C}.Release|Any CPU.ActiveCfg = Release|Any CPU 75 | {30E51278-0B54-4186-8CBC-DB75C3B9AD4C}.Release|Any CPU.Build.0 = Release|Any CPU 76 | {A60372F8-9F36-4F4C-B752-9351E004E8A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {A60372F8-9F36-4F4C-B752-9351E004E8A7}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {A60372F8-9F36-4F4C-B752-9351E004E8A7}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {A60372F8-9F36-4F4C-B752-9351E004E8A7}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {C8114227-E594-48D4-B798-BCFE47513F0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 81 | {C8114227-E594-48D4-B798-BCFE47513F0E}.Debug|Any CPU.Build.0 = Debug|Any CPU 82 | {C8114227-E594-48D4-B798-BCFE47513F0E}.Release|Any CPU.ActiveCfg = Release|Any CPU 83 | {C8114227-E594-48D4-B798-BCFE47513F0E}.Release|Any CPU.Build.0 = Release|Any CPU 84 | {BF41B1FF-EC8F-4362-830C-0D48CA7046C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 85 | {BF41B1FF-EC8F-4362-830C-0D48CA7046C7}.Debug|Any CPU.Build.0 = Debug|Any CPU 86 | {BF41B1FF-EC8F-4362-830C-0D48CA7046C7}.Release|Any CPU.ActiveCfg = Release|Any CPU 87 | {BF41B1FF-EC8F-4362-830C-0D48CA7046C7}.Release|Any CPU.Build.0 = Release|Any CPU 88 | {4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 89 | {4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3}.Debug|Any CPU.Build.0 = Debug|Any CPU 90 | {4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3}.Release|Any CPU.ActiveCfg = Release|Any CPU 91 | {4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3}.Release|Any CPU.Build.0 = Release|Any CPU 92 | {58364AAE-F852-4F64-ABD8-45ECB683B3F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 93 | {58364AAE-F852-4F64-ABD8-45ECB683B3F1}.Debug|Any CPU.Build.0 = Debug|Any CPU 94 | {58364AAE-F852-4F64-ABD8-45ECB683B3F1}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 | {58364AAE-F852-4F64-ABD8-45ECB683B3F1}.Release|Any CPU.Build.0 = Release|Any CPU 96 | {7E57ABC3-40E2-4423-8C1E-0664E7296D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 97 | {7E57ABC3-40E2-4423-8C1E-0664E7296D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU 98 | {7E57ABC3-40E2-4423-8C1E-0664E7296D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU 99 | {7E57ABC3-40E2-4423-8C1E-0664E7296D8B}.Release|Any CPU.Build.0 = Release|Any CPU 100 | {58517299-ED91-40D3-8D30-08135268FDFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 101 | {58517299-ED91-40D3-8D30-08135268FDFE}.Debug|Any CPU.Build.0 = Debug|Any CPU 102 | {58517299-ED91-40D3-8D30-08135268FDFE}.Release|Any CPU.ActiveCfg = Release|Any CPU 103 | {58517299-ED91-40D3-8D30-08135268FDFE}.Release|Any CPU.Build.0 = Release|Any CPU 104 | {A459C86D-D0DD-4CAE-AFEE-21103F91D7A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 105 | {A459C86D-D0DD-4CAE-AFEE-21103F91D7A2}.Debug|Any CPU.Build.0 = Debug|Any CPU 106 | {A459C86D-D0DD-4CAE-AFEE-21103F91D7A2}.Release|Any CPU.ActiveCfg = Release|Any CPU 107 | {A459C86D-D0DD-4CAE-AFEE-21103F91D7A2}.Release|Any CPU.Build.0 = Release|Any CPU 108 | {C20D0E2D-3708-4432-8FC1-BC25AAA9BB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 109 | {C20D0E2D-3708-4432-8FC1-BC25AAA9BB66}.Debug|Any CPU.Build.0 = Debug|Any CPU 110 | {C20D0E2D-3708-4432-8FC1-BC25AAA9BB66}.Release|Any CPU.ActiveCfg = Release|Any CPU 111 | {C20D0E2D-3708-4432-8FC1-BC25AAA9BB66}.Release|Any CPU.Build.0 = Release|Any CPU 112 | {2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 113 | {2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0}.Debug|Any CPU.Build.0 = Debug|Any CPU 114 | {2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0}.Release|Any CPU.ActiveCfg = Release|Any CPU 115 | {2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0}.Release|Any CPU.Build.0 = Release|Any CPU 116 | {7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 117 | {7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1}.Debug|Any CPU.Build.0 = Debug|Any CPU 118 | {7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1}.Release|Any CPU.ActiveCfg = Release|Any CPU 119 | {7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1}.Release|Any CPU.Build.0 = Release|Any CPU 120 | {760DC19C-0613-4816-8642-C125FB11E3CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 121 | {760DC19C-0613-4816-8642-C125FB11E3CF}.Debug|Any CPU.Build.0 = Debug|Any CPU 122 | {760DC19C-0613-4816-8642-C125FB11E3CF}.Release|Any CPU.ActiveCfg = Release|Any CPU 123 | {760DC19C-0613-4816-8642-C125FB11E3CF}.Release|Any CPU.Build.0 = Release|Any CPU 124 | {3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 125 | {3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585}.Debug|Any CPU.Build.0 = Debug|Any CPU 126 | {3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585}.Release|Any CPU.ActiveCfg = Release|Any CPU 127 | {3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585}.Release|Any CPU.Build.0 = Release|Any CPU 128 | {1E48C083-7544-4884-A13F-49787A031959}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 129 | {1E48C083-7544-4884-A13F-49787A031959}.Debug|Any CPU.Build.0 = Debug|Any CPU 130 | {1E48C083-7544-4884-A13F-49787A031959}.Release|Any CPU.ActiveCfg = Release|Any CPU 131 | {1E48C083-7544-4884-A13F-49787A031959}.Release|Any CPU.Build.0 = Release|Any CPU 132 | {89A9F824-BA1E-4841-983C-22F97FEBBA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 133 | {89A9F824-BA1E-4841-983C-22F97FEBBA13}.Debug|Any CPU.Build.0 = Debug|Any CPU 134 | {89A9F824-BA1E-4841-983C-22F97FEBBA13}.Release|Any CPU.ActiveCfg = Release|Any CPU 135 | {89A9F824-BA1E-4841-983C-22F97FEBBA13}.Release|Any CPU.Build.0 = Release|Any CPU 136 | {9AE50016-502E-4E3A-B6A2-A408836C8CBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 137 | {9AE50016-502E-4E3A-B6A2-A408836C8CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU 138 | {9AE50016-502E-4E3A-B6A2-A408836C8CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU 139 | {9AE50016-502E-4E3A-B6A2-A408836C8CBC}.Release|Any CPU.Build.0 = Release|Any CPU 140 | {7A4D13F3-B03B-4FD6-B756-C0342874C78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 141 | {7A4D13F3-B03B-4FD6-B756-C0342874C78C}.Debug|Any CPU.Build.0 = Debug|Any CPU 142 | {7A4D13F3-B03B-4FD6-B756-C0342874C78C}.Release|Any CPU.ActiveCfg = Release|Any CPU 143 | {7A4D13F3-B03B-4FD6-B756-C0342874C78C}.Release|Any CPU.Build.0 = Release|Any CPU 144 | {2A396F40-9A86-473F-A3E6-54A09F716E61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 145 | {2A396F40-9A86-473F-A3E6-54A09F716E61}.Debug|Any CPU.Build.0 = Debug|Any CPU 146 | {2A396F40-9A86-473F-A3E6-54A09F716E61}.Release|Any CPU.ActiveCfg = Release|Any CPU 147 | {2A396F40-9A86-473F-A3E6-54A09F716E61}.Release|Any CPU.Build.0 = Release|Any CPU 148 | {6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 149 | {6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C}.Debug|Any CPU.Build.0 = Debug|Any CPU 150 | {6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C}.Release|Any CPU.ActiveCfg = Release|Any CPU 151 | {6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C}.Release|Any CPU.Build.0 = Release|Any CPU 152 | {2F5CFC18-647D-44C7-9384-A703C228F3EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 153 | {2F5CFC18-647D-44C7-9384-A703C228F3EA}.Debug|Any CPU.Build.0 = Debug|Any CPU 154 | {2F5CFC18-647D-44C7-9384-A703C228F3EA}.Release|Any CPU.ActiveCfg = Release|Any CPU 155 | {2F5CFC18-647D-44C7-9384-A703C228F3EA}.Release|Any CPU.Build.0 = Release|Any CPU 156 | {28177887-5DBC-4AE9-9857-3277B9B17C0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 157 | {28177887-5DBC-4AE9-9857-3277B9B17C0F}.Debug|Any CPU.Build.0 = Debug|Any CPU 158 | {28177887-5DBC-4AE9-9857-3277B9B17C0F}.Release|Any CPU.ActiveCfg = Release|Any CPU 159 | {28177887-5DBC-4AE9-9857-3277B9B17C0F}.Release|Any CPU.Build.0 = Release|Any CPU 160 | EndGlobalSection 161 | GlobalSection(SolutionProperties) = preSolution 162 | HideSolutionNode = FALSE 163 | EndGlobalSection 164 | GlobalSection(NestedProjects) = preSolution 165 | {30E51278-0B54-4186-8CBC-DB75C3B9AD4C} = {6D05E481-BEC3-436A-8772-7750E27ED35F} 166 | {A60372F8-9F36-4F4C-B752-9351E004E8A7} = {6D05E481-BEC3-436A-8772-7750E27ED35F} 167 | {C8114227-E594-48D4-B798-BCFE47513F0E} = {6D05E481-BEC3-436A-8772-7750E27ED35F} 168 | {BF41B1FF-EC8F-4362-830C-0D48CA7046C7} = {6D05E481-BEC3-436A-8772-7750E27ED35F} 169 | {4EB6B79B-5AB0-4084-94C0-BB3C3EC648E3} = {6D05E481-BEC3-436A-8772-7750E27ED35F} 170 | {58364AAE-F852-4F64-ABD8-45ECB683B3F1} = {E2BDE344-F699-4641-8177-D61643FF0E77} 171 | {7E57ABC3-40E2-4423-8C1E-0664E7296D8B} = {E2BDE344-F699-4641-8177-D61643FF0E77} 172 | {58517299-ED91-40D3-8D30-08135268FDFE} = {E2BDE344-F699-4641-8177-D61643FF0E77} 173 | {A459C86D-D0DD-4CAE-AFEE-21103F91D7A2} = {8F0830DA-CD72-47A3-A775-D2F672CF6892} 174 | {C20D0E2D-3708-4432-8FC1-BC25AAA9BB66} = {8F0830DA-CD72-47A3-A775-D2F672CF6892} 175 | {2B4F1B4D-64D5-4EB9-A9DC-28C3DA9872D0} = {A0B17314-4E7C-4D4C-BD6F-9AA9271F06D8} 176 | {7A8C4EBD-6F11-486C-975B-5C29A7A5EBE1} = {8677A733-C74C-4B6D-A4E4-7608997CC35A} 177 | {760DC19C-0613-4816-8642-C125FB11E3CF} = {8677A733-C74C-4B6D-A4E4-7608997CC35A} 178 | {3ED6BA5F-63F9-4E0E-A02D-E1BD2DD61585} = {8677A733-C74C-4B6D-A4E4-7608997CC35A} 179 | {1E48C083-7544-4884-A13F-49787A031959} = {F5282FE9-C4AB-4D87-9BEA-1C0B0F468D07} 180 | {89A9F824-BA1E-4841-983C-22F97FEBBA13} = {F5282FE9-C4AB-4D87-9BEA-1C0B0F468D07} 181 | {9AE50016-502E-4E3A-B6A2-A408836C8CBC} = {A60C031B-F32B-4518-A292-184C06182A65} 182 | {7A4D13F3-B03B-4FD6-B756-C0342874C78C} = {A60C031B-F32B-4518-A292-184C06182A65} 183 | {8677A733-C74C-4B6D-A4E4-7608997CC35A} = {8F0830DA-CD72-47A3-A775-D2F672CF6892} 184 | {E2BDE344-F699-4641-8177-D61643FF0E77} = {8F0830DA-CD72-47A3-A775-D2F672CF6892} 185 | {2A396F40-9A86-473F-A3E6-54A09F716E61} = {F5282FE9-C4AB-4D87-9BEA-1C0B0F468D07} 186 | {92CD5C69-0F1F-4573-BFF2-F3F63A2887A6} = {A60C031B-F32B-4518-A292-184C06182A65} 187 | {F5282FE9-C4AB-4D87-9BEA-1C0B0F468D07} = {A60C031B-F32B-4518-A292-184C06182A65} 188 | {6754A1B2-AB2D-44F4-B320-A8CD4FFDC34C} = {92CD5C69-0F1F-4573-BFF2-F3F63A2887A6} 189 | {2F5CFC18-647D-44C7-9384-A703C228F3EA} = {92CD5C69-0F1F-4573-BFF2-F3F63A2887A6} 190 | {28177887-5DBC-4AE9-9857-3277B9B17C0F} = {92CD5C69-0F1F-4573-BFF2-F3F63A2887A6} 191 | EndGlobalSection 192 | GlobalSection(ExtensibilityGlobals) = postSolution 193 | SolutionGuid = {2B005474-9C8C-4BB1-A4CF-9E4BA3EB5C24} 194 | EndGlobalSection 195 | EndGlobal 196 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pubsubdemo 2 | A pub/sub scenario with MassTransit, RabbitMQ and .NET Core 3 | 4 | Documentation: 5 | 6 | https://medium.com/@alikzlda/a-simple-pub-sub-scenario-with-masstransit-6-2-rabbitmq-net-core-3-1-elasticsearch-mssql-5a65c993b2fd 7 | 8 | ## The article has been shared in #RabbitMQ Community Writings. 9 | https://blog.rabbitmq.com/posts/2020/06/this-month-in-rabbitmq-april-2020-recap 10 | --------------------------------------------------------------------------------