-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAzureServiceBusBusFactory.cs
45 lines (39 loc) · 1.34 KB
/
AzureServiceBusBusFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
}
}
}