diff --git a/build.ps1 b/build.ps1 index 661c408..ae9db1a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,3 @@ -#Disable Telemetry -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 - #Skip the NuGet package cache generation $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..b455b2b --- /dev/null +++ b/readme.md @@ -0,0 +1,86 @@ +#OpenMessage + +Master Branch: ![Build Status](https://im5tu.visualstudio.com/_apis/public/build/definitions/e4fcda74-9f33-4672-b774-b4419099857c/2/badge) + +Dev Branch: ![Build Status](https://im5tu.visualstudio.com/_apis/public/build/definitions/e4fcda74-9f33-4672-b774-b4419099857c/5/badge) + +OpenMessage aims to simplify the service bus paradigm by using pre-existing patterns to build an extensible architecture. + +##Getting Started + +The library is based around the `Microsoft.Extensions.*` packages and relies upon the abstractions for depenency injection and logging allowing you the freedom to pick the implementations that best suit your scenario. + +Assuming you want to connect to Azure Service Bus, here is how you configure OpenMessage: + +1 - Add the provider: + + PM> Install-Package OpenMessage.Providers.Azure + +2 - Add the serializer (or write your own): + + PM> Install-Package OpenMessage.Serializer.JsonNet + +3 - Add the services to your service collection: + + using OpenMessage; + using OpenMessage.Providers.Azure.Configuration; + using OpenMessage.Serializer.JsonNet; + + ... + + IServiceCollection AddServices(IServiceCollection services) + { + return services + .AddOpenMessage() + .AddJsonNetSerializer() + .Configure(config => { + config.ConnectionString = "YOUR CONNECTION STRING HERE"); + }); + } + +###Sending Messages + +4 - Add either a Queue/Topic dispatcher to the service collection: + + IServiceCollection AddQueueBindings(IServiceCollection services) + { + return services.AddQueueDispatcher(); + } + +5 - Inject an `IDispatcher` into your class of choice: + + internal class CommandGenerator + { + private readonly IDispatcher _dispatcher; + + public CommandGenerator(IDispatcher dispatcher) + { + _dispatcher = dispatcher; + } + } + +###Receiving Messages + +4 - Add either a Queue/Subscription observable to the service collection: + + IServiceCollection AddQueueBindings(IServiceCollection services) + { + return services.AddQueueObservable(); + } + +5 - When done, resolve an `IEnumerable` from the service collection to begin receiving messages. + +##Serializers + +You can add more than one serializer to OpenMessage. In this scenario, all registered serializers are checked to see whether they can deserialize the message. When serializing the last registered serializer is used, service collection provider depending. + +- [x] [Json.Net](http://www.nuget.org/packages/OpenMessage.Serializer.JsonNet/) +- [x] [Jil](http://www.nuget.org/packages/OpenMessage.Serializer.Jil/) +- [x] [Protobuf](http://www.nuget.org/packages/OpenMessage.Serializer.ProtobufNet/) + +##Providers + +- [x] [Azure Service Bus](http://www.nuget.org/packages/OpenMessage.Providers.Azure/) +- [ ] Azure Event Hubs +- [ ] In Memory +- [ ] Rabbit MQ \ No newline at end of file diff --git a/src/OpenMessage.Providers.Azure/Management/TopicClient.cs b/src/OpenMessage.Providers.Azure/Management/TopicClient.cs index 7e76a0b..ed60f7f 100644 --- a/src/OpenMessage.Providers.Azure/Management/TopicClient.cs +++ b/src/OpenMessage.Providers.Azure/Management/TopicClient.cs @@ -42,7 +42,7 @@ public async Task SendAsync(T entity, TimeSpan scheduleIn) throw new ArgumentException("You cannot schedule a message to arrive in the past; time travel isn't a thing yet."); var message = Serialize(entity); - if (scheduleIn > TimeSpan.MinValue) + if (scheduleIn > TimeSpan.Zero) message.ScheduledEnqueueTimeUtc = DateTime.UtcNow + scheduleIn; Logger.LogInformation($"Sending message of type: {TypeName}"); diff --git a/src/OpenMessage.Providers.Azure/project.json b/src/OpenMessage.Providers.Azure/project.json index 736de44..1c8c776 100644 --- a/src/OpenMessage.Providers.Azure/project.json +++ b/src/OpenMessage.Providers.Azure/project.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0", "Microsoft.Extensions.Logging.Abstractions": "1.0.0",