Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 from Im5tu/dev
Browse files Browse the repository at this point in the history
Dev to master
  • Loading branch information
Im5tu authored Jan 25, 2017
2 parents de09c6e + 5cfaefd commit 143db50
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
3 changes: 0 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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

Expand Down
86 changes: 86 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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<OpenMessageAzureProviderOptions>(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<MyType>();
}

5 - Inject an `IDispatcher<T>` into your class of choice:

internal class CommandGenerator
{
private readonly IDispatcher<MyType> _dispatcher;
public CommandGenerator(IDispatcher<MyType> dispatcher)
{
_dispatcher = dispatcher;
}
}

###Receiving Messages

4 - Add either a Queue/Subscription observable to the service collection:

IServiceCollection AddQueueBindings(IServiceCollection services)
{
return services.AddQueueObservable<MyType>();
}

5 - When done, resolve an `IEnumerable<IBroker>` 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
2 changes: 1 addition & 1 deletion src/OpenMessage.Providers.Azure/Management/TopicClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down
2 changes: 1 addition & 1 deletion src/OpenMessage.Providers.Azure/project.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 143db50

Please sign in to comment.