Example #1
0
        public static IServiceBus Create(
            Action <IMassInstanceBusFactoryConfigurator> configure,
            IMassInstanceConsumerFactory consumerFactory)
        {
            var topologyConfiguration    = new RabbitMqTopologyConfiguration(MessageTopology);
            var busConfiguration         = new RabbitMqBusConfiguration(topologyConfiguration);
            var busEndpointConfiguration = busConfiguration.CreateEndpointConfiguration();

            var sagaMessageExtractor = new SagaMessageExtractor();

            var configurator = new MassInstanceBusFactoryConfigurator(
                busConfiguration,
                busEndpointConfiguration,
                consumerFactory,
                sagaMessageExtractor);

            configure(configurator);

            var result = BusConfigurationResult.CompileResults(configurator.Validate());

            try
            {
                return(configurator.CreateBus());
            }
            catch (Exception ex)
            {
                throw new ConfigurationException(result, "An exception occurred during bus creation", ex);
            }
        }
Example #2
0
        /// <summary>
        /// Configure and create a bus for RabbitMQ
        /// </summary>
        /// <param name="configure">The configuration callback to configure the bus</param>
        /// <returns></returns>
        public static IBusControl Create(Action <IRabbitMqBusFactoryConfigurator> configure)
        {
            var topologyConfiguration    = new RabbitMqTopologyConfiguration(MessageTopology);
            var busConfiguration         = new RabbitMqBusConfiguration(topologyConfiguration);
            var busEndpointConfiguration = busConfiguration.CreateEndpointConfiguration();

            var configurator = new RabbitMqBusFactoryConfigurator(busConfiguration, busEndpointConfiguration);

            configure(configurator);

            return(configurator.Build());
        }