Beispiel #1
0
        public static IUnityContainer CreateContainer(IApplicationInfo appInfo)
        {
            var regClient = new RegistryServiceClient(appInfo);
            var hostName = regClient.GetResourceLocation(RegistryResourceType.ServiceHost, "rabbitmq", 1);

            var factory = new ConnectionFactory
            {
                UserName = "******",
                Password = "******",
                VirtualHost = "/",
                HostName = hostName,
                AutomaticRecoveryEnabled = true,
                NetworkRecoveryInterval = TimeSpan.FromSeconds(5),
                RequestedHeartbeat = 5,
            };

            return new UnityContainer()
                        .RegisterInstance<IConnectionFactory>(factory)
                        .RegisterType<IConnection, RabbitMqConnection>(new ContainerControlledLifetimeManager())
                        .RegisterType<IModel, RabbitMqModel>(new HierarchicalLifetimeManager());
        }