public void Configure(AbstractRhinoServiceBusConfiguration configuration, IBusContainerBuilder builder)
        {
            var busConfig = configuration as RhinoServiceBusConfiguration;

            if (busConfig == null)
            {
                return;
            }

            if (configuration.Endpoint.Scheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase) ==
                false)
            {
                return;
            }

            var busConfigSection = configuration.ConfigurationSection.Bus;

            if (string.IsNullOrEmpty(busConfigSection.Name))
            {
                throw new ConfigurationErrorsException(
                          "Could not find attribute 'name' in node 'bus' in configuration");
            }

            builder.RegisterRhinoQueuesTransport();
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var oneWayConfig = config as OnewayRhinoServiceBusConfiguration;
            if (oneWayConfig == null)
                return;

            var messageOwners = new List<MessageOwner>();
            var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);
            messageOwnersReader.ReadMessageOwners();
            oneWayConfig.MessageOwners = messageOwners.ToArray();
            // JED - TODO
            // Bad coupling - extend or rewrite?
            var scheme = messageOwnersReader.EndpointScheme;
            if (IsRhinoQueues(scheme))
            {
                builder.RegisterRhinoQueuesOneWay();
            }
            else if (IsMsmq(scheme))
            {
                builder.RegisterMsmqOneWay();
            }
            else if (IsAmazonSQS(scheme))
            {
                builder.RegisterAmazonSQSOneWay();
            }
            else
            {
                throw new ApplicationException(string.Format("Unknown endpoint scheme '{0}'", scheme));
            }
        }
		private void RegisterSqlQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
		{
			var busConfig = c.ConfigurationSection.Bus;

			b.RegisterSingleton<IStorage>(() => new SqlStorage(busConfig.Path ?? QueueConnectionStringContainer.ConnectionString));

			b.RegisterSingleton<ISubscriptionStorage>(() => new GenericSubscriptionStorage(
			                                                	l.Resolve<IStorage>(),
			                                                	c.Endpoint.ToString(),
			                                                	l.Resolve<IMessageSerializer>(),
			                                                	l.Resolve<IReflection>()));

			b.RegisterSingleton<ITransport>(() => new SqlQueuesTransport(
			                                      	c.Endpoint,
			                                      	l.Resolve<IEndpointRouter>(),
			                                      	l.Resolve<IMessageSerializer>(),
			                                      	c.ThreadCount,
													busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
			                                      	c.NumberOfRetries,
			                                      	l.Resolve<IMessageBuilder<MessagePayload>>()));

			b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => new SqlQueuesMessageBuilder(
			                                                           	l.Resolve<IMessageSerializer>(),
			                                                           	l.Resolve<IServiceLocator>()));
		}
        private void RegisterRhinoQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var busConfig = c.ConfigurationSection.Bus;
            var fileManagerConfiguration = new QueueManagerConfiguration();

            b.RegisterSingleton<ISubscriptionStorage>(() => (ISubscriptionStorage)new FileSubscriptionStorage(
                busConfig.SubscriptionPath,
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IReflection>()));

            b.RegisterSingleton<ITransport>(() => (ITransport)new RhinoFilesTransport(
                c.Endpoint,
                l.Resolve<IEndpointRouter>(),
                l.Resolve<IMessageSerializer>(),
                c.ThreadCount,
                busConfig.QueuePath,
                c.IsolationLevel,
                c.NumberOfRetries,
                busConfig.EnablePerformanceCounters,
                l.Resolve<IMessageBuilder<MessagePayload>>(),
                fileManagerConfiguration));

            b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => (IMessageBuilder<MessagePayload>)new RhinoFilesMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<QueueManagerConfiguration>(() => fileManagerConfiguration);
        }
Exemple #5
0
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;

            if (busConfig == null)
            {
                return;
            }
            if (config.ConfigurationSection.Security.Key == null)
            {
                builder.RegisterNoSecurity();
                return;
            }

            var key = config.ConfigurationSection.Security.Key;

            if (string.IsNullOrEmpty(key))
            {
                throw new ConfigurationErrorsException("<security> element must have a <key> element with content");
            }

            var keyBuffer = Convert.FromBase64String(key);

            builder.RegisterSecurity(keyBuffer);
        }
Exemple #6
0
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;

            if (busConfig == null)
            {
                return;
            }

            var uriString = config.ConfigurationSection.Bus.LogEndpoint;

            if (string.IsNullOrEmpty(uriString))
            {
                return;
            }

            Uri logEndpoint;

            if (!Uri.TryCreate(uriString, UriKind.Absolute, out logEndpoint))
            {
                throw new ConfigurationErrorsException(
                          "Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");
            }

            builder.RegisterLoggingEndpoint(logEndpoint);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;

            var busElement = config.ConfigurationSection.Bus;

            if (busElement == null)
                return;

            var loadBalancerEndpointAsString = busElement.LoadBalancerEndpoint;

            if (string.IsNullOrEmpty(loadBalancerEndpointAsString))
                return;

            Uri loadBalancerEndpoint;
            if (!Uri.TryCreate(loadBalancerEndpointAsString, UriKind.Absolute, out loadBalancerEndpoint))
                throw new ConfigurationErrorsException(
                    "Attribute 'loadBalancerEndpoint' on 'bus' has an invalid value '" + loadBalancerEndpointAsString + "'");

            var endpoint = new Endpoint { Uri = loadBalancerEndpoint };
            builder.RegisterLoadBalancerEndpoint(endpoint.Uri);
            config.AddMessageModule<LoadBalancerMessageModule>();
        }
		public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
		{
			var busConfig = config as RhinoServiceBusConfiguration;
			if (busConfig == null)
				return;

			if (!config.Endpoint.Scheme.Equals("sql.queues", StringComparison.InvariantCultureIgnoreCase))
				return;

			RegisterSqlQueuesTransport(config, builder, locator);
		}
Exemple #9
0
        private void RegisterMsmqOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;

            b.RegisterSingleton <IMessageBuilder <Message> >(() => (IMessageBuilder <Message>) new MsmqMessageBuilder(
                                                                 l.Resolve <IMessageSerializer>(),
                                                                 l.Resolve <IServiceLocator>()));

            b.RegisterSingleton <IOnewayBus>(() => (IOnewayBus) new MsmqOnewayBus(
                                                 oneWayConfig.MessageOwners,
                                                 l.Resolve <IMessageBuilder <Message> >()));
        }
        private void RegisterMsmqOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;

            b.RegisterSingleton<IMessageBuilder<Message>>(() => (IMessageBuilder<Message>)new MsmqMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<IOnewayBus>(() => (IOnewayBus)new MsmqOnewayBus(
                oneWayConfig.MessageOwners,
                l.Resolve<IMessageBuilder<Message>>(),oneWayConfig.ConfigurationSection.Bus.UseDeadLetterQueue));
        }
Exemple #11
0
        private void RegisterMsmqTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l, Type queueStrategyType)
        {
            if (queueStrategyType == typeof(FlatQueueStrategy))
            {
                b.RegisterSingleton <IQueueStrategy>(() => (IQueueStrategy) new FlatQueueStrategy(
                                                         l.Resolve <IEndpointRouter>(),
                                                         c.Endpoint));
            }
            else
            {
                b.RegisterSingleton <IQueueStrategy>(() => (IQueueStrategy) new SubQueueStrategy());
            }

            if (c.UseDtc)
            {
                b.RegisterSingleton <ITransactionStrategy>(() => new TransactionScopeStrategy());
            }
            else
            {
                b.RegisterSingleton <ITransactionStrategy>(() => new MsmqTransactionStrategy());
            }

            b.RegisterSingleton <IMessageBuilder <Message> >(() => (IMessageBuilder <Message>) new MsmqMessageBuilder(
                                                                 l.Resolve <IMessageSerializer>(),
                                                                 l.Resolve <IServiceLocator>()));

            b.RegisterSingleton <IMsmqTransportAction>(Guid.NewGuid().ToString(), () => (IMsmqTransportAction) new ErrorAction(
                                                           c.NumberOfRetries,
                                                           l.Resolve <IQueueStrategy>()));

            b.RegisterSingleton <ISubscriptionStorage>(() => (ISubscriptionStorage) new MsmqSubscriptionStorage(
                                                           l.Resolve <IReflection>(),
                                                           l.Resolve <IMessageSerializer>(),
                                                           c.Endpoint,
                                                           l.Resolve <IEndpointRouter>(),
                                                           l.Resolve <IQueueStrategy>()));

            b.RegisterSingleton <ITransport>(() => (ITransport) new MsmqTransport(
                                                 l.Resolve <IMessageSerializer>(),
                                                 l.Resolve <IQueueStrategy>(),
                                                 c.Endpoint,
                                                 c.ThreadCount,
                                                 l.ResolveAll <IMsmqTransportAction>().ToArray(),
                                                 l.Resolve <IEndpointRouter>(),
                                                 c.IsolationLevel,
                                                 c.Transactional,
                                                 c.ConsumeInTransaction,
                                                 l.Resolve <IMessageBuilder <Message> >(),
                                                 l.Resolve <ITransactionStrategy>()));

            b.RegisterAll <IMsmqTransportAction>(typeof(ErrorAction));
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var loadBalancerConfig = config as LoadBalancer.LoadBalancerConfiguration;
            if (loadBalancerConfig == null)
                return;

            if (loadBalancerConfig.SecondaryLoadBalancer != null)
                builder.RegisterSecondaryLoadBalancer();
            else
                builder.RegisterPrimaryLoadBalancer();

            if (loadBalancerConfig.ReadyForWork != null)
                builder.RegisterReadyForWork();
        }
		private void RegisterSqlQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
		{
			var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
			var busConfig = c.ConfigurationSection.Bus;

			b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => new SqlQueuesMessageBuilder(
				l.Resolve<IMessageSerializer>(),
				l.Resolve<IServiceLocator>()));

			b.RegisterSingleton<IOnewayBus>(() => new SqlQueuesOneWayBus(
				oneWayConfig.MessageOwners,
				l.Resolve<IMessageSerializer>(),
				busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
				l.Resolve<IMessageBuilder<MessagePayload>>()));
		}
Exemple #14
0
        private void RegisterSqlQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
            var busConfig    = c.ConfigurationSection.Bus;

            b.RegisterSingleton <IMessageBuilder <MessagePayload> >(() => new SqlQueuesMessageBuilder(
                                                                        l.Resolve <IMessageSerializer>(),
                                                                        l.Resolve <IServiceLocator>()));

            b.RegisterSingleton <IOnewayBus>(() => new SqlQueuesOneWayBus(
                                                 oneWayConfig.MessageOwners,
                                                 l.Resolve <IMessageSerializer>(),
                                                 busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
                                                 l.Resolve <IMessageBuilder <MessagePayload> >()));
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;

            if (busConfig == null)
            {
                return;
            }

            if (!config.Endpoint.Scheme.Equals("sql.queues", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            RegisterSqlQueuesTransport(config, builder, locator);
        }
        private void RegisterRhinoQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
            var busConfig = c.ConfigurationSection.Bus;

            b.RegisterSingleton<IMessageBuilder<MessagePayload>>(() => (IMessageBuilder<MessagePayload>)new RhinoQueuesMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<IOnewayBus>(() => (IOnewayBus)new RhinoQueuesOneWayBus(
                oneWayConfig.MessageOwners,
                l.Resolve<IMessageSerializer>(),
                busConfig.QueuePath,
                busConfig.EnablePerformanceCounters,
                l.Resolve<IMessageBuilder<MessagePayload>>()));
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            if (!(config is RhinoServiceBusConfiguration) && !(config is LoadBalancer.LoadBalancerConfiguration))
                return;

            if (!config.Endpoint.Scheme.Equals("msmq", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (config.UseFlatQueue)
                queueStrategyImpl = typeof(FlatQueueStrategy);

            if (!config.DisableAutoQueueCreation)
                RegisterQueueCreation(builder, locator);

            RegisterMsmqTransport(config, builder, locator, queueStrategyImpl);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var oneWayConfig = config as OnewayRhinoServiceBusConfiguration;
            if (oneWayConfig == null)
                return;

            var messageOwners = new List<MessageOwner>();
            var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);
            messageOwnersReader.ReadMessageOwners();

            if (!messageOwnersReader.EndpointScheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase))
                return;

            oneWayConfig.MessageOwners = messageOwners.ToArray();
            RegisterRhinoQueuesOneWay(config, builder, locator);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;

            if (!config.Endpoint.Scheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase))
                return;

            var busConfigSection = config.ConfigurationSection.Bus;

            if (string.IsNullOrEmpty(busConfigSection.Name))
                throw new ConfigurationErrorsException(
                    "Could not find attribute 'name' in node 'bus' in configuration");

            RegisterRhinoQueuesTransport(config, builder, locator);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var busConfig = config as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;

            var uriString = config.ConfigurationSection.Bus.LogEndpoint;
            if (string.IsNullOrEmpty(uriString))
                return;

            Uri logEndpoint;
            if (!Uri.TryCreate(uriString, UriKind.Absolute, out logEndpoint))
                throw new ConfigurationErrorsException(
                    "Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");

            builder.RegisterLoggingEndpoint(logEndpoint);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var oneWayConfig = config as OnewayRhinoServiceBusConfiguration;
            if (oneWayConfig == null)
                return;

            var messageOwners = new List<MessageOwner>();
            var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);
            messageOwnersReader.ReadMessageOwners();
            oneWayConfig.MessageOwners = messageOwners.ToArray();
            if (IsRhinoQueues(messageOwnersReader.EndpointScheme))
            {
                builder.RegisterRhinoQueuesOneWay();
            }
            else
            {
                builder.RegisterMsmqOneWay();
            }
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var busConfig = config as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;
            if (config.ConfigurationSection.Security.Key == null)
            {
                builder.RegisterNoSecurity();
                return;
            }

            var key = config.ConfigurationSection.Security.Key;
            if (string.IsNullOrEmpty(key))
                throw new ConfigurationErrorsException("<security> element must have a <key> element with content");

            var keyBuffer = Convert.FromBase64String(key);

            builder.RegisterSecurity(keyBuffer);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration configuration, IBusContainerBuilder builder)
        {
            if (!(configuration is RhinoServiceBusConfiguration) && !(configuration is LoadBalancer.LoadBalancerConfiguration))
                return;

            if (configuration.Endpoint.Scheme.Equals("msmq", StringComparison.InvariantCultureIgnoreCase) == false)
                return;

            if (configuration.UseFlatQueue)
            {
                queueStrategyImpl = typeof (FlatQueueStrategy);
            }

            if (configuration.DisableAutoQueueCreation == false)
            {
                builder.RegisterQueueCreation();
            }

            builder.RegisterMsmqTransport(queueStrategyImpl);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var busConfig = config as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;

            Uri logEndpoint;

            var uriString = config.ConfigurationSection.Bus.LogEndpoint;
            if (string.IsNullOrEmpty(uriString))
                return;

            if (Uri.TryCreate(uriString, UriKind.Absolute, out logEndpoint) == false)
            {
                throw new ConfigurationErrorsException(
                    "Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");
            }
            builder.RegisterLoggingEndpoint(logEndpoint);
            config.InsertMessageModuleAtFirst<MessageLoggingModule>();
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var busConfig = config as RhinoServiceBusConfiguration;

            if (busConfig == null)
            {
                return;
            }

            var busElement = config.ConfigurationSection.Bus;

            if (busElement == null)
            {
                return;
            }

            var loadBalancerEndpointAsString = busElement.LoadBalancerEndpoint;

            if (string.IsNullOrEmpty(loadBalancerEndpointAsString))
            {
                return;
            }

            Uri loadBalancerEndpoint;

            if (Uri.TryCreate(
                    loadBalancerEndpointAsString,
                    UriKind.Absolute,
                    out loadBalancerEndpoint) == false)
            {
                throw new ConfigurationErrorsException(
                          "Attribute 'loadBalancerEndpoint' on 'bus' has an invalid value '" + loadBalancerEndpointAsString + "'");
            }

            var endpoint = new Endpoint {
                Uri = loadBalancerEndpoint
            };

            builder.RegisterLoadBalancerEndpoint(endpoint.Uri);
            config.AddMessageModule <LoadBalancerMessageModule>();
        }
Exemple #26
0
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            var oneWayConfig = config as OnewayRhinoServiceBusConfiguration;

            if (oneWayConfig == null)
            {
                return;
            }

            var messageOwners       = new List <MessageOwner>();
            var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);

            messageOwnersReader.ReadMessageOwners();

            if (!messageOwnersReader.EndpointScheme.Equals("rhino.queues", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            oneWayConfig.MessageOwners = messageOwners.ToArray();
            RegisterRhinoQueuesOneWay(config, builder, locator);
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var loadBalancerConfig = config as LoadBalancer.LoadBalancerConfiguration;

            if (loadBalancerConfig == null)
            {
                return;
            }
            if (loadBalancerConfig.SecondaryLoadBalancer != null)
            {
                builder.RegisterSecondaryLoadBalancer();
            }
            else
            {
                builder.RegisterPrimaryLoadBalancer();
            }

            if (loadBalancerConfig.ReadyForWork != null)
            {
                builder.RegisterReadyForWork();
            }
        }
        public void Configure(AbstractRhinoServiceBusConfiguration configuration, IBusContainerBuilder builder)
        {
            var busConfig = configuration as RhinoServiceBusConfiguration;
            if (busConfig == null)
                return;

            if (configuration.Endpoint.Scheme.Equals("sql.queues", StringComparison.InvariantCultureIgnoreCase) ==
                false)
                return;

            var busConfigSection = configuration.ConfigurationSection.Bus;

            if (string.IsNullOrEmpty(busConfigSection.Name))
                throw new ConfigurationErrorsException(
                    "Could not find attribute 'name' in node 'bus' in configuration");

            if (string.IsNullOrEmpty(DefaultHost.QueueConnectionString))
                throw new ConfigurationErrorsException(
                    "Could not find connection string QueueConnection in application configuration file");

            builder.RegisterSqlQueuesTransport();
        }
        private void RegisterMsmqTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l, Type queueStrategyType)
        {
            if (queueStrategyType == typeof(FlatQueueStrategy))
                b.RegisterSingleton<IQueueStrategy>(() => (IQueueStrategy)new FlatQueueStrategy(
                    l.Resolve<IEndpointRouter>(),
                    c.Endpoint));
            else
                b.RegisterSingleton<IQueueStrategy>(() => (IQueueStrategy)new SubQueueStrategy());

            b.RegisterSingleton<IMessageBuilder<Message>>(() => (IMessageBuilder<Message>)new MsmqMessageBuilder(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IServiceLocator>()));

            b.RegisterSingleton<IMsmqTransportAction>(Guid.NewGuid().ToString(), () => (IMsmqTransportAction)new ErrorAction(
                c.NumberOfRetries,
                l.Resolve<IQueueStrategy>()));

            b.RegisterSingleton<ISubscriptionStorage>(() => (ISubscriptionStorage)new MsmqSubscriptionStorage(
                l.Resolve<IReflection>(),
                l.Resolve<IMessageSerializer>(),
                c.Endpoint,
                l.Resolve<IEndpointRouter>(),
                l.Resolve<IQueueStrategy>()));

            b.RegisterSingleton<ITransport>(() => (ITransport)new MsmqTransport(
                l.Resolve<IMessageSerializer>(),
                l.Resolve<IQueueStrategy>(),
                c.Endpoint,
                c.ThreadCount,
                l.ResolveAll<IMsmqTransportAction>().ToArray(),
                l.Resolve<IEndpointRouter>(),
                c.IsolationLevel,
                c.Transactional,
                c.ConsumeInTransaction,
                l.Resolve<IMessageBuilder<Message>>()));

            b.RegisterAll<IMsmqTransportAction>(typeof(ErrorAction));
        }
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder)
        {
            var oneWayConfig = config as OnewayRhinoServiceBusConfiguration;

            if (oneWayConfig == null)
            {
                return;
            }

            var messageOwners       = new List <MessageOwner>();
            var messageOwnersReader = new MessageOwnersConfigReader(config.ConfigurationSection, messageOwners);

            messageOwnersReader.ReadMessageOwners();
            oneWayConfig.MessageOwners = messageOwners.ToArray();
            if (IsRhinoQueues(messageOwnersReader.EndpointScheme))
            {
                builder.RegisterRhinoQueuesOneWay();
            }
            else
            {
                builder.RegisterMsmqOneWay();
            }
        }
        public void Configure(AbstractRhinoServiceBusConfiguration configuration, IBusContainerBuilder builder)
        {
            if (!(configuration is RhinoServiceBusConfiguration) && !(configuration is LoadBalancer.LoadBalancerConfiguration))
            {
                return;
            }

            if (configuration.Endpoint.Scheme.Equals("msmq", StringComparison.InvariantCultureIgnoreCase) == false)
            {
                return;
            }

            if (configuration.UseFlatQueue)
            {
                queueStrategyImpl = typeof(FlatQueueStrategy);
            }

            if (configuration.DisableAutoQueueCreation == false)
            {
                builder.RegisterQueueCreation();
            }

            builder.RegisterMsmqTransport(queueStrategyImpl);
        }
Exemple #32
0
        public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainerBuilder builder, IServiceLocator locator)
        {
            if (!(config is RhinoServiceBusConfiguration) && !(config is LoadBalancer.LoadBalancerConfiguration))
            {
                return;
            }

            if (!config.Endpoint.Scheme.Equals("msmq", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            if (config.UseFlatQueue)
            {
                queueStrategyImpl = typeof(FlatQueueStrategy);
            }

            if (!config.DisableAutoQueueCreation)
            {
                RegisterQueueCreation(builder, locator);
            }

            RegisterMsmqTransport(config, builder, locator, queueStrategyImpl);
        }
 public void BuildWith(IBusContainerBuilder builder)
 {
     busContainerBuilder = builder;
     builder.WithInterceptor(new ConsumerInterceptor());
 }
 private void RegisterQueueCreation(IBusContainerBuilder b, IServiceLocator l)
 {
     b.RegisterSingleton<IServiceBusAware>(Guid.NewGuid().ToString(), () => (IServiceBusAware)new QueueCreationModule(
         l.Resolve<IQueueStrategy>()));
 }
Exemple #35
0
        private void RegisterRhinoQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var busConfig = c.ConfigurationSection.Bus;
            var queueManagerConfiguration = new QueueManagerConfiguration();

            b.RegisterSingleton <ISubscriptionStorage>(() => (ISubscriptionStorage) new PhtSubscriptionStorage(
                                                           busConfig.SubscriptionPath,
                                                           l.Resolve <IMessageSerializer>(),
                                                           l.Resolve <IReflection>()));

            b.RegisterSingleton <ITransactionStrategy>(() => new TransactionScopeStrategy());

            b.RegisterSingleton <ITransport>(() => (ITransport) new RhinoQueuesTransport(
                                                 c.Endpoint,
                                                 l.Resolve <IEndpointRouter>(),
                                                 l.Resolve <IMessageSerializer>(),
                                                 c.ThreadCount,
                                                 busConfig.QueuePath,
                                                 c.IsolationLevel,
                                                 c.NumberOfRetries,
                                                 busConfig.EnablePerformanceCounters,
                                                 l.Resolve <IMessageBuilder <MessagePayload> >(),
                                                 queueManagerConfiguration,
                                                 l.Resolve <ITransactionStrategy>()));

            b.RegisterSingleton <IMessageBuilder <MessagePayload> >(() => (IMessageBuilder <MessagePayload>) new RhinoQueuesMessageBuilder(
                                                                        l.Resolve <IMessageSerializer>(),
                                                                        l.Resolve <IServiceLocator>()));

            b.RegisterSingleton <QueueManagerConfiguration>(() => queueManagerConfiguration);
        }
        private void RegisterSqlQueuesTransport(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var busConfig = c.ConfigurationSection.Bus;

            b.RegisterSingleton <IStorage>(() => new SqlStorage(busConfig.Path ?? QueueConnectionStringContainer.ConnectionString));

            b.RegisterSingleton <ISubscriptionStorage>(() => new GenericSubscriptionStorage(
                                                           l.Resolve <IStorage>(),
                                                           c.Endpoint.ToString(),
                                                           l.Resolve <IMessageSerializer>(),
                                                           l.Resolve <IReflection>()));

            b.RegisterSingleton <ITransport>(() => new SqlQueuesTransport(
                                                 c.Endpoint,
                                                 l.Resolve <IEndpointRouter>(),
                                                 l.Resolve <IMessageSerializer>(),
                                                 c.ThreadCount,
                                                 busConfig.Path ?? QueueConnectionStringContainer.ConnectionString,
                                                 c.NumberOfRetries,
                                                 l.Resolve <IMessageBuilder <MessagePayload> >()));

            b.RegisterSingleton <IMessageBuilder <MessagePayload> >(() => new SqlQueuesMessageBuilder(
                                                                        l.Resolve <IMessageSerializer>(),
                                                                        l.Resolve <IServiceLocator>()));
        }
Exemple #37
0
 private void RegisterQueueCreation(IBusContainerBuilder b, IServiceLocator l)
 {
     b.RegisterSingleton <IServiceBusAware>(Guid.NewGuid().ToString(), () => (IServiceBusAware) new QueueCreationModule(
                                                l.Resolve <IQueueStrategy>()));
 }
Exemple #38
0
        private void RegisterRhinoQueuesOneWay(AbstractRhinoServiceBusConfiguration c, IBusContainerBuilder b, IServiceLocator l)
        {
            var oneWayConfig = (OnewayRhinoServiceBusConfiguration)c;
            var busConfig    = c.ConfigurationSection.Bus;
            var queueManagerConfiguration = new QueueManagerConfiguration();

            b.RegisterSingleton <IMessageBuilder <MessagePayload> >(() => (IMessageBuilder <MessagePayload>) new RhinoQueuesMessageBuilder(
                                                                        l.Resolve <IMessageSerializer>(),
                                                                        l.Resolve <IServiceLocator>()));

            b.RegisterSingleton <IOnewayBus>(() => (IOnewayBus) new RhinoQueuesOneWayBus(
                                                 oneWayConfig.MessageOwners,
                                                 l.Resolve <IMessageSerializer>(),
                                                 busConfig.QueuePath,
                                                 busConfig.EnablePerformanceCounters,
                                                 l.Resolve <IMessageBuilder <MessagePayload> >(),
                                                 queueManagerConfiguration));

            b.RegisterSingleton <QueueManagerConfiguration>(() => queueManagerConfiguration);
        }