Skip to content

fredrikn/SimpleServiceBus

Repository files navigation

Simple Service Bus

Create a Command:

    public class CreateUser : Command
    {
        public string Name { get; set; }
    }

Create a Client that sends the command through the ServiceBus:

    using (var bus = ServiceBus.Create<Startup>())
    {
        bus.Send(new CreateUser() {Name = "John Doe"});
    }

Client configuration Startup.cs:

    class Startup : IStartup
    {
        public void Configuration(IClientConfig config)
        {
            //config.UseWcfMsmq();
            config.UseWcfBasicHttp();
        }
    }

Create a server/host and add a command handler for the command

Command handler example:

    public class CreateUserCommandHandler : ICommandHandler<CreateUser>
    {
        public void Handle(CreateUser command)
        {
            Console.WriteLine(command.Name);
        }
    }

Host:

    using (ServiceBusHost.Start<Startup>())
    {
        Console.WriteLine("Running. Press ENTER to close exit.");
        Console.ReadLine();
    }

Host configuration, Startup.cs

    public class Startup : IStartup
    {
        public void Configuration(IHostConfig config)
        {
            //config.UseWcfMsmq();
            config.UseWcfBasicHttp();
        }
    }

About

This is a simple Service bus.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages