-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
64 lines (55 loc) · 2.56 KB
/
Program.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Autofac;
using EventBus;
using EventBus.Abstractions;
using EventBus.IBMMQ;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Sample.Shared;
using System;
using System.Collections.Generic;
namespace Sample.IBMMQ.Consumer
{
class Program
{
const string APP_NAME = "IBMMQ APP Consumer";
static void Main(string[] args)
{
var services = new ServiceCollection() as IServiceCollection;
ConfigureServices(services);
while (true) System.Threading.Thread.Sleep(2000);
}
//docker run --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --publish 1414:1414 --publish 9443:9443 ibmcom/mq
static void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IIBMMQPersistentConnection>(sp =>
{
var config = new Dictionary<string, string>
{
["userid"] = Environment.GetEnvironmentVariable("IBMMQ_USERID"),//app
["password"] = Environment.GetEnvironmentVariable("IBMMQ_PASSWORD"),//passw0rd
["topic"] = Environment.GetEnvironmentVariable("IBMMQ_TOPIC"),//"dev/"
["host"] = Environment.GetEnvironmentVariable("IBMMQ_HOST"),//"localhost"
["port"] = Environment.GetEnvironmentVariable("IBMMQ_PORT"),// 1414
["channel"] = Environment.GetEnvironmentVariable("IBMMQ_CHANNEL"),//"DEV.APP.SVRCONN"
["qmgr"] = Environment.GetEnvironmentVariable("IBMMQ_QMGR"),//"*QM1TLS"
};
var logger = sp.GetRequiredService<ILogger<DefaultIBMMQPersistentConnection>>();
return new DefaultIBMMQPersistentConnection(logger, config);
});
services.AddSingleton<IEventBus, EventBusIBMMQ>(sp =>
{
var persistentConnection = sp.GetRequiredService<IIBMMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusIBMMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
return new EventBusIBMMQ(persistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager);
});
services
.AddEventBusConfigure()
.AddIntegrationEventHandler();
services
.ServiceProviderBuild()
.RunSampleConsumer(APP_NAME);
}
}
}