1
0
mirror of synced 2024-11-16 06:43:51 +00:00
Tapeti/Test/Program.cs

68 lines
2.2 KiB
C#
Raw Normal View History

using System;
using SimpleInjector;
using Tapeti;
2017-02-12 20:43:30 +00:00
using Tapeti.DataAnnotations;
using Tapeti.Flow;
using Tapeti.Flow.SQL;
2017-02-12 20:43:30 +00:00
using Tapeti.Helpers;
using Tapeti.SimpleInjector;
namespace Test
{
internal class Program
{
private static void Main()
{
// TODO SQL based flow store
// TODO logging
// TODO uitzoeken of we consumers kunnen pauzeren (denk: SQL down) --> nee, EFDBContext Get Async maken en retryen? kan dat, of timeout dan Rabbit?
var container = new Container();
2016-12-07 09:19:16 +00:00
container.Register<MarcoEmitter>();
container.Register<Visualizer>();
2016-12-07 09:19:16 +00:00
//container.Register<IFlowRepository>(() => new EF(serviceID));
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
.WithFlow()
//.WithFlowSqlRepository("data source=localhost;initial catalog=lef;integrated security=True;multipleactiveresultsets=True", 1)
2017-02-12 20:43:30 +00:00
.WithDataAnnotations()
2016-12-07 09:19:16 +00:00
.RegisterAllControllers()
.Build();
using (var connection = new TapetiConnection(config)
{
Params = new TapetiAppSettingsConnectionParams()
})
{
connection.Connected += (sender, e) => {
Console.WriteLine("Event Connected");
};
connection.Disconnected += (sender, e) => {
Console.WriteLine("Event Disconnected");
};
connection.Reconnected += (sender, e) => {
Console.WriteLine("Event Reconnected");
};
Console.WriteLine("Subscribing...");
var subscriber = connection.Subscribe(false).Result;
Console.WriteLine("Consuming...");
subscriber.Resume().Wait();
Console.WriteLine("Done!");
connection.GetPublisher().Publish(new FlowEndController.PingMessage());
container.GetInstance<IFlowStarter>().Start<MarcoController>(c => c.StartFlow);
var emitter = container.GetInstance<MarcoEmitter>();
emitter.Run().Wait();
}
}
}
}