Source

Starling / source / Starling.Sample / Systems / OrderProcessing / OrderProcessorSystem.cs

Full commit
using System;
using System.ComponentModel;
using System.Messaging;
using Starling.Activation;
using Starling.Integration.Msmq;
using Starling.Sample.Messages;
using Starling.Sample.Systems.OrderProcessing.Handlers;
using Starling.Subscription;

namespace Starling.Sample.Systems.OrderProcessing
{
    [DisplayName("Order processor")]
    [Description("When an order is submitted via the UI, this process orchestrates the steps needed to confirm and process the order.")]
    public class OrderProcessorSystem : ISystem
    {
        public void Start()
        {
            var queue = new MessageQueue(QueueNames.OrderProcessor);
            queue.Formatter = new XmlMessageFormatter(new[] { typeof(SubmitOrderMessage) });
            var listener = new MsmqListener(queue);
            var registry = new HandlerRegistry(new HandlerMetadataInspector());
            registry.RegisterHandler(typeof(SubmitOrderHandler));
            var dispatcher = new MessageDispatcher(listener, registry, new DefaultHandlerFactory());
            dispatcher.Start();
        }
    }
}