Commit d3f70b84 authored by boncho vylkov's avatar boncho vylkov

add the eventbus.rabbitmq

parent 7f965f8a
......@@ -20,6 +20,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EasyNetQ" Version="3.4.4" />
<PackageReference Include="EventBus.EventBusRabbitMQ" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
......
......@@ -33,6 +33,11 @@
using Newtonsoft.Json;
using MvcCoreTemplate.Services;
using EventBus.EventBusRabbitMQ;
using RabbitMQ.Client;
using EventBus.Library.Abstractions;
using Autofac;
using EventBus.Library;
public class Startup
{
......@@ -105,6 +110,51 @@
services.AddSingleton(this.configuration);
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
{
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory()
{
HostName = "localhost" //Configuration["EventBusConnection"]
};
//if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
//{
// factory.UserName = Configuration["EventBusUserName"];
//}
//if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
//{
// factory.Password = Configuration["EventBusPassword"];
//}
var retryCount = 5;
//if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
//{
// retryCount = int.Parse(Configuration["EventBusRetryCount"]);
//}
return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
});
services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp =>
{
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
var retryCount = 5;
var subscriptionClientName = "MvcCoreTemplateClient";//Configuration["SubscriptionClientName"];
//if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
//{
// retryCount = int.Parse(Configuration["EventBusRetryCount"]);
//}
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
});
// Data repositories
services.AddScoped(typeof(IDeletableEntityRepository<>), typeof(EfDeletableEntityRepository<>));
services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment