2016-11-20 13:34:50 +00:00
|
|
|
|
using System;
|
2017-09-22 09:19:49 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2016-11-20 13:34:50 +00:00
|
|
|
|
using SimpleInjector;
|
|
|
|
|
using Tapeti;
|
2017-02-12 20:43:30 +00:00
|
|
|
|
using Tapeti.DataAnnotations;
|
2017-01-31 11:01:08 +00:00
|
|
|
|
using Tapeti.Flow;
|
2017-02-08 14:52:24 +00:00
|
|
|
|
using Tapeti.Flow.SQL;
|
2017-02-12 20:43:30 +00:00
|
|
|
|
using Tapeti.Helpers;
|
2016-11-20 13:34:50 +00:00
|
|
|
|
using Tapeti.SimpleInjector;
|
2017-10-17 08:34:07 +00:00
|
|
|
|
using System.Threading;
|
2016-11-20 13:34:50 +00:00
|
|
|
|
|
|
|
|
|
namespace Test
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
private static void Main()
|
|
|
|
|
{
|
2017-02-07 15:13:33 +00:00
|
|
|
|
// TODO SQL based flow store
|
|
|
|
|
// TODO logging
|
2017-02-08 14:52:24 +00:00
|
|
|
|
// TODO uitzoeken of we consumers kunnen pauzeren (denk: SQL down) --> nee, EFDBContext Get Async maken en retryen? kan dat, of timeout dan Rabbit?
|
2017-02-07 15:13:33 +00:00
|
|
|
|
|
2016-11-20 13:34:50 +00:00
|
|
|
|
var container = new Container();
|
2016-12-07 09:19:16 +00:00
|
|
|
|
container.Register<MarcoEmitter>();
|
2016-12-13 21:01:43 +00:00
|
|
|
|
container.Register<Visualizer>();
|
2017-08-30 15:47:43 +00:00
|
|
|
|
container.Register<ILogger, Tapeti.Default.ConsoleLogger>();
|
2016-12-07 09:19:16 +00:00
|
|
|
|
|
2017-02-08 14:52:24 +00:00
|
|
|
|
//container.Register<IFlowRepository>(() => new EF(serviceID));
|
2017-02-07 17:22:28 +00:00
|
|
|
|
|
2017-02-07 15:13:33 +00:00
|
|
|
|
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
|
2017-02-05 22:22:34 +00:00
|
|
|
|
.WithFlow()
|
2017-02-12 20:43:30 +00:00
|
|
|
|
.WithDataAnnotations()
|
2016-12-07 09:19:16 +00:00
|
|
|
|
.RegisterAllControllers()
|
|
|
|
|
.Build();
|
2016-11-20 13:34:50 +00:00
|
|
|
|
|
2017-02-05 22:22:34 +00:00
|
|
|
|
using (var connection = new TapetiConnection(config)
|
|
|
|
|
{
|
2017-02-08 14:52:24 +00:00
|
|
|
|
Params = new TapetiAppSettingsConnectionParams()
|
2017-02-05 22:22:34 +00:00
|
|
|
|
})
|
|
|
|
|
{
|
2017-10-17 08:34:07 +00:00
|
|
|
|
var flowStore = container.GetInstance<IFlowStore>();
|
|
|
|
|
var flowStore2 = container.GetInstance<IFlowStore>();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("IFlowHandler is singleton = " + (flowStore == flowStore2));
|
|
|
|
|
|
2017-07-14 10:33:09 +00:00
|
|
|
|
connection.Connected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Connected");
|
|
|
|
|
};
|
|
|
|
|
connection.Disconnected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Disconnected");
|
|
|
|
|
};
|
|
|
|
|
connection.Reconnected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Reconnected");
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-20 13:34:50 +00:00
|
|
|
|
Console.WriteLine("Subscribing...");
|
2017-02-12 18:04:26 +00:00
|
|
|
|
var subscriber = connection.Subscribe(false).Result;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Consuming...");
|
|
|
|
|
subscriber.Resume().Wait();
|
|
|
|
|
|
2016-11-20 13:34:50 +00:00
|
|
|
|
Console.WriteLine("Done!");
|
|
|
|
|
|
2017-07-25 13:50:38 +00:00
|
|
|
|
connection.GetPublisher().Publish(new FlowEndController.PingMessage());
|
|
|
|
|
|
2017-09-22 09:19:49 +00:00
|
|
|
|
container.GetInstance<IFlowStarter>().Start<MarcoController, bool>(c => c.StartFlow, true);
|
2017-02-15 21:05:01 +00:00
|
|
|
|
|
2017-10-17 08:34:07 +00:00
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
2016-12-05 07:00:09 +00:00
|
|
|
|
var emitter = container.GetInstance<MarcoEmitter>();
|
|
|
|
|
emitter.Run().Wait();
|
2017-07-25 13:50:38 +00:00
|
|
|
|
|
|
|
|
|
|
2016-11-20 13:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|