Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
StarterKit-MassTransit/StarterKit.Service/Configuration/AzureServiceBusBusFactory.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
45 lines (39 sloc)
1.34 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace StarterKit.Service.Configuration | |
{ | |
using Autofac; | |
using GreenPipes; | |
using MassTransit; | |
using MassTransit.AzureServiceBusTransport; | |
using Module.Consumers; | |
using System; | |
using System.Collections.Generic; | |
public class AzureServiceBusBusFactory : IBusFactory | |
{ | |
private readonly IComponentContext _componentContext; | |
public AzureServiceBusBusFactory(IComponentContext componentContext) | |
{ | |
_componentContext = componentContext; | |
} | |
public IBusControl CreateBus() | |
{ | |
return Bus.Factory.CreateUsingAzureServiceBus(cfg => | |
{ | |
var azureSbConnString = Environment.GetEnvironmentVariable("AzureSbConnectionString"); | |
var host = cfg.Host(azureSbConnString, h => | |
{ | |
}); | |
cfg.UseServiceBusMessageScheduler(); | |
// Add Receive Endpoint | |
cfg.ReceiveEndpoint(host, "queue-dosomeworkservice", e => | |
{ | |
e.Consumer<DoSomeWorkConsumer>(_componentContext); | |
e.PrefetchCount = 4 * Environment.ProcessorCount; | |
}); | |
}); | |
} | |
public IEnumerable<ValidationResult> Validate() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |