2016-11-20 13:34:50 +00:00
|
|
|
|
using System;
|
2019-04-24 16:04:30 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
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;
|
2016-11-20 13:34:50 +00:00
|
|
|
|
using Tapeti.SimpleInjector;
|
2017-10-17 08:34:07 +00:00
|
|
|
|
using System.Threading;
|
2019-04-24 16:04:30 +00:00
|
|
|
|
using Tapeti.Annotations;
|
2019-04-25 13:19:51 +00:00
|
|
|
|
using Tapeti.Transient;
|
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 logging
|
2019-04-25 13:19:51 +00:00
|
|
|
|
//try
|
2019-01-24 21:52:21 +00:00
|
|
|
|
{
|
|
|
|
|
var container = new Container();
|
|
|
|
|
container.Register<MarcoEmitter>();
|
|
|
|
|
container.Register<Visualizer>();
|
|
|
|
|
container.Register<ILogger, Tapeti.Default.ConsoleLogger>();
|
2018-06-12 08:12:52 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
|
|
|
|
|
//.WithFlowSqlRepository("Server=localhost;Database=TapetiTest;Integrated Security=true")
|
|
|
|
|
.WithFlow()
|
|
|
|
|
.WithDataAnnotations()
|
2019-04-25 13:19:51 +00:00
|
|
|
|
.WithTransient(TimeSpan.FromSeconds(30))
|
2019-01-24 21:52:21 +00:00
|
|
|
|
.RegisterAllControllers()
|
|
|
|
|
//.DisablePublisherConfirms() -> you probably never want to do this if you're using Flow or want requeues when a publish fails
|
|
|
|
|
.Build();
|
2016-11-20 13:34:50 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
using (var connection = new TapetiConnection(config)
|
|
|
|
|
{
|
|
|
|
|
Params = new TapetiAppSettingsConnectionParams()
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
var flowStore = container.GetInstance<IFlowStore>();
|
|
|
|
|
var flowStore2 = container.GetInstance<IFlowStore>();
|
2017-10-17 08:34:07 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
Console.WriteLine("IFlowHandler is singleton = " + (flowStore == flowStore2));
|
2017-10-17 08:34:07 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +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"); };
|
2017-07-14 10:33:09 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
Console.WriteLine("Subscribing...");
|
|
|
|
|
var subscriber = connection.Subscribe(false).Result;
|
2017-02-12 18:04:26 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
Console.WriteLine("Consuming...");
|
|
|
|
|
subscriber.Resume().Wait();
|
2017-02-12 18:04:26 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
Console.WriteLine("Done!");
|
2016-11-20 13:34:50 +00:00
|
|
|
|
|
2019-04-25 13:19:51 +00:00
|
|
|
|
var response = container.GetInstance<ITransientPublisher>()
|
|
|
|
|
.RequestResponse<PoloConfirmationRequestMessage, PoloConfirmationResponseMessage>(
|
|
|
|
|
new PoloConfirmationRequestMessage
|
|
|
|
|
{
|
|
|
|
|
StoredInState = new Guid("309088d8-9906-4ef3-bc64-56976538d3ab")
|
|
|
|
|
}).Result;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(response.ShouldMatchState);
|
|
|
|
|
|
|
|
|
|
//connection.GetPublisher().Publish(new FlowEndController.PingMessage());
|
2017-07-25 13:50:38 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
//container.GetInstance<IFlowStarter>().Start<MarcoController, bool>(c => c.StartFlow, true).Wait();
|
2019-04-25 13:19:51 +00:00
|
|
|
|
//container.GetInstance<IFlowStarter>().Start<MarcoController>(c => c.TestParallelRequest).Wait();
|
2017-02-15 21:05:01 +00:00
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
Thread.Sleep(1000);
|
2017-10-17 08:34:07 +00:00
|
|
|
|
|
2019-04-25 13:19:51 +00:00
|
|
|
|
//var emitter = container.GetInstance<MarcoEmitter>();
|
|
|
|
|
//emitter.Run().Wait();
|
2017-07-25 13:50:38 +00:00
|
|
|
|
|
|
|
|
|
|
2019-01-24 21:52:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-25 13:19:51 +00:00
|
|
|
|
//catch (Exception e)
|
2019-01-24 21:52:21 +00:00
|
|
|
|
{
|
2019-04-25 13:19:51 +00:00
|
|
|
|
// Console.WriteLine(e.ToString());
|
|
|
|
|
// Console.ReadKey();
|
2016-11-20 13:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|