/Weave

The missing event-driven framework for .NET

Primary LanguageC#MIT LicenseMIT

Weave

Build status

The missing event-driven framework for .NET

Contains a high-level abstraction for the following EIP patterns

  1. Point-to-point channel
  2. Publish-subscribe channel
  3. Message bus
  4. Routing Slip

Usage

Contains implementation based on MassTransit. Sample code is using RabbitMq transport.

Create Endpoint

var endpoint = new RabbitMqEndpointBuilder()
                .WithContainerConfigurator(new AutofacContainerConfigurator(containerBuilder))
                .WithMessageTypeTopology("Test_Application_Name")
                .WithTopologyFeaturesConfiguration(new DefaultRabbitMqTopologyFeaturesConfiguration())
                .Build();

Create Messaging Module

    public sealed class TestMessagingModule : MessagingModule
    {
        protected override void Load(IMessagingModuleBuilder builder)
        {
            // Query
            builder.WithHandler<TestQueryHandler>();
            // Command
            builder.WithHandler<TestCommandHandler>();
            // Event
            builder.WithHandler<TestEventHandler>();
            
            // Sagas
            builder.WithSaga<TestSaga>();
        }
    }

Register Messaging Module

endpoint.RegisterMessagingModule(new TestMessagingModule());

Finish Configuration

endpoint.Configure();

var messageBus = endpoint.CreateMessageBus();

Run

// Query (fetch, direct, p2p)
await messageBus.RequestAsync(new TestQuery()).ConfigureAwait(false);

// Command (execute, direct/broadcast)
await messageBus.SendAsync(new TestCommand()).ConfigureAwait(false);

// Event (Pub-sub)
await messageBus.Publish(new TestEvent { OrderId = i }).ConfigureAwait(false);