diff --git a/IConnection.cs b/IConnection.cs index 92f5ce5..b9671be 100644 --- a/IConnection.cs +++ b/IConnection.cs @@ -1,9 +1,10 @@ using System; +using System.Threading.Tasks; namespace Tapeti { public interface IConnection : IDisposable { - ISubscriber Subscribe(); + Task Subscribe(); } } diff --git a/Tapeti.Saga/ISaga.cs b/Tapeti.Saga/ISaga.cs new file mode 100644 index 0000000..bd9f01a --- /dev/null +++ b/Tapeti.Saga/ISaga.cs @@ -0,0 +1,13 @@ +using System; + +namespace Tapeti.Saga +{ + public interface ISaga : IDisposable where T : class + { + string Id { get; } + T State { get; } + + void ExpectResponse(string callId); + void ResolveResponse(string callId); + } +} diff --git a/Tapeti.Saga/ISagaProvider.cs b/Tapeti.Saga/ISagaProvider.cs new file mode 100644 index 0000000..b6d3d63 --- /dev/null +++ b/Tapeti.Saga/ISagaProvider.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; + +namespace Tapeti.Saga +{ + public interface ISagaProvider + { + Task> Begin() where T : class; + Task> Continue(string sagaId) where T : class; + Task> Current() where T : class; + } +} diff --git a/Tapeti.Saga/ISagaStore.cs b/Tapeti.Saga/ISagaStore.cs new file mode 100644 index 0000000..839be22 --- /dev/null +++ b/Tapeti.Saga/ISagaStore.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; + +namespace Tapeti.Saga +{ + public interface ISagaStore + { + Task Read(string sagaId); + Task Update(string sagaId, object state); + } +} diff --git a/Tapeti.Saga/Properties/AssemblyInfo.cs b/Tapeti.Saga/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..785eee1 --- /dev/null +++ b/Tapeti.Saga/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tapeti.Saga")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Hewlett-Packard Company")] +[assembly: AssemblyProduct("Tapeti.Saga")] +[assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f84ad920-d5a1-455d-aed5-2542b3a47b85")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tapeti.Saga/Tapeti.Saga.csproj b/Tapeti.Saga/Tapeti.Saga.csproj new file mode 100644 index 0000000..525f86d --- /dev/null +++ b/Tapeti.Saga/Tapeti.Saga.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {F84AD920-D5A1-455D-AED5-2542B3A47B85} + Library + Properties + Tapeti.Saga + Tapeti.Saga + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tapeti.sln b/Tapeti.sln index 49530f0..16ebd8f 100644 --- a/Tapeti.sln +++ b/Tapeti.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.SimpleInjector", "Ta EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{90559950-1B32-4119-A78E-517E2C71EE23}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.Saga", "Tapeti.Saga\Tapeti.Saga.csproj", "{F84AD920-D5A1-455D-AED5-2542B3A47B85}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {90559950-1B32-4119-A78E-517E2C71EE23}.Debug|Any CPU.Build.0 = Debug|Any CPU {90559950-1B32-4119-A78E-517E2C71EE23}.Release|Any CPU.ActiveCfg = Release|Any CPU {90559950-1B32-4119-A78E-517E2C71EE23}.Release|Any CPU.Build.0 = Release|Any CPU + {F84AD920-D5A1-455D-AED5-2542B3A47B85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F84AD920-D5A1-455D-AED5-2542B3A47B85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F84AD920-D5A1-455D-AED5-2542B3A47B85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F84AD920-D5A1-455D-AED5-2542B3A47B85}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Test/MarcoController.cs b/Test/MarcoController.cs new file mode 100644 index 0000000..9c955eb --- /dev/null +++ b/Test/MarcoController.cs @@ -0,0 +1,91 @@ +using System; +using Microsoft.SqlServer.Server; +using Tapeti; +using Tapeti.Annotations; + +namespace Test +{ + [DynamicQueue] + public class MarcoController : MessageController + { + private readonly IPublisher publisher; + + + public MarcoController(IPublisher publisher/*, ISagaProvider sagaProvider*/) + { + this.publisher = publisher; + } + + + //[StaticQueue("test")] + public PoloMessage Marco(MarcoMessage message) + { + /* + using (sagaProvider.Begin(new MarcoState + { + ... + })) + { + //publisher.Publish(new PoloColorRequest(), saga, PoloColorResponse1); + //publisher.Publish(new PoloColorRequest(), saga, callID = "tweede"); + + // Saga refcount = 2 + } + */ + + return new PoloMessage(); ; + } + + + /* + [CallID("eerste")] + Implicit: + + using (sagaProvider.Continue(correlatieID)) + { + saga refcount--; + public void PoloColorResponse1(PoloColorResponse message, ISaga saga) + { + + saga.State == MarcoState + + + + state.Color = message.Color; + + if (state.Complete) + { + publisher.Publish(new PoloMessage()); + } + } + */ + + public void Polo(PoloMessage message) + { + Console.WriteLine("Polo!"); + } + } + + + public class MarcoMessage + { + } + + + public class PoloMessage + { + } + + + + + public class PoloColorRequest + { + + } + + public class PoloColorResponse + { + + } +} diff --git a/Test/Program.cs b/Test/Program.cs index e20454d..df7b22f 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -10,18 +10,19 @@ namespace Test private static void Main() { var container = new Container(); + container.Register(); + + + var topology = new TapetiTopologyBuilder() + .RegisterAllControllers() + .Build(); using (var connection = new TapetiConnectionBuilder() .SetExchange("test") .SetDependencyResolver(new SimpleInjectorDependencyResolver(container)) - .SetTopology( - new TapetiTopologyBuilder() - .RegisterAllControllers() - .Build()) + .SetTopology(topology) .Build()) - { - container.Register(); - + { Console.WriteLine("Subscribing..."); connection.Subscribe().Wait(); Console.WriteLine("Done!"); diff --git a/Test/Test.csproj b/Test/Test.csproj index 98eb7c2..a66fa9f 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -51,7 +51,7 @@ - + diff --git a/Test/TestQueueController.cs b/Test/TestQueueController.cs deleted file mode 100644 index c408bce..0000000 --- a/Test/TestQueueController.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Tapeti; -using Tapeti.Annotations; - -namespace Test -{ - [DynamicQueue] - public class TestQueueController : MessageController - { - private readonly IPublisher publisher; - - - public TestQueueController(IPublisher publisher) - { - this.publisher = publisher; - } - - - public PoloMessage Marco(MarcoMessage message) - { - Console.WriteLine("Marco!"); - return new PoloMessage(); - } - - - public void Polo(PoloMessage message) - { - Console.WriteLine("Polo!"); - } - } - - - public class MarcoMessage - { - } - - - public class PoloMessage - { - } -}