コード例 #1
0
        public void SetUp()
        {
            actionWasInvoked = false;
            actionThreadName = "Not set";

            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var connection = MockRepository.GenerateStub<IPersistentConnection>();
            var channelFactory = MockRepository.GenerateStub<IPersistentChannelFactory>();
            channel = MockRepository.GenerateStub<IPersistentChannel>();

            Action<IModel> action = x =>
                {
                    actionWasInvoked = true;
                    actionThreadName = Thread.CurrentThread.Name;
                };

            channelFactory.Stub(x => x.CreatePersistentChannel(connection)).Return(channel);
            channel.Stub(x => x.InvokeChannelAction(null)).IgnoreArguments().WhenCalled(
                x => ((Action<IModel>)x.Arguments[0])(null));

            dispatcher = new ClientCommandDispatcher(configuration, connection, channelFactory);

            dispatcher.InvokeAsync(action).Wait();
        }
コード例 #2
0
 public void SetUp()
 {
     var parser = new ConnectionStringParser();
     var configuration = parser.Parse("host=localhost");
     logger = MockRepository.GenerateStub<IEasyNetQLogger>();
     dispatcherFactory = new ConsumerDispatcherFactory(configuration, logger);
 }
コード例 #3
0
        public void The_validate_method_should_apply_AMQPconnection_idempotently()
        {
            ConnectionConfiguration connectionConfiguration = new ConnectionStringParser().Parse("amqp://amqphost:1234/");
            connectionConfiguration.Validate(); // Simulates additional call to .Validate(); made by some RabbitHutch.CreateBus(...) overloads, in addition to call within ConnectionStringParser.Parse().

            connectionConfiguration.Hosts.Count().ShouldEqual(1);
            connectionConfiguration.Hosts.Single().Host.ShouldEqual("amqphost");
            connectionConfiguration.Hosts.Single().Port.ShouldEqual(1234);
        }
コード例 #4
0
ファイル: RabbitHutch.cs プロジェクト: richard-green/EasyNetQ
        /// <summary>
        /// Creates a new instance of RabbitBus.
        /// </summary>
        /// <param name="connectionString">
        /// The EasyNetQ connection string. Example:
        /// host=192.168.1.1;port=5672;virtualHost=MyVirtualHost;username=MyUsername;password=MyPassword;requestedHeartbeat=10
        /// 
        /// The following default values will be used if not specified:
        /// host=localhost;port=5672;virtualHost=/;username=guest;password=guest;requestedHeartbeat=0
        /// </param>
        /// <param name="registerServices">
        /// Override default services. For example, to override the default IEasyNetQLogger:
        /// RabbitHutch.CreateBus("host=localhost", x => x.Register&lt;IEasyNetQLogger&gt;(_ => myLogger));
        /// </param>
        /// <returns>
        /// A new RabbitBus instance.
        /// </returns>
        public static IBus CreateBus(string connectionString, Action<IServiceRegister> registerServices)
        {
            Preconditions.CheckNotNull(connectionString, "connectionString");
            Preconditions.CheckNotNull(registerServices, "registerServices");

            var connectionStringParser = new ConnectionStringParser();

            var connectionConfiguration = connectionStringParser.Parse(connectionString);

            return CreateBus(connectionConfiguration, registerServices);
        }
コード例 #5
0
 public void SetUp()
 {
     var logger = new ConsoleLogger();
     var eventBus = new EventBus();
     var parser = new ConnectionStringParser();
     var configuration = parser.Parse("host=localhost");
     var hostSelectionStrategy = new RandomClusterHostSelectionStrategy<ConnectionFactoryInfo>();
     var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
     connection = new PersistentConnection(connectionFactory, logger, eventBus);
     persistentChannel = new PersistentChannel(connection, logger, configuration, new EventBus());
 }
コード例 #6
0
        public void SetUp()
        {
            var eventBus = new EventBus();
            var logger = new ConsoleLogger();
            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var hostSelectionStrategy = new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>();
            var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
            connection = new PersistentConnection(connectionFactory, logger, eventBus);
            var persistentChannelFactory = new PersistentChannelFactory(logger, configuration, eventBus);

            dispatcher = new ClientCommandDispatcher(connection, persistentChannelFactory);
        }
コード例 #7
0
        public void Should_not_have_case_sensitive_keys()
        {
            const string connectionStringAlternateCasing =
                "Host=192.168.1.1:1001,my.little.host:1002;VirtualHost=Copa;UserName=Copa;" +
                "Password=abc_xyz;Port=12345;RequestedHeartbeat=3";

            var parsed = new ConnectionStringParser().Parse(connectionStringAlternateCasing);
            parsed.Hosts.First().Host.ShouldEqual("192.168.1.1");
            parsed.Hosts.First().Port.ShouldEqual(1001);
            parsed.VirtualHost.ShouldEqual("Copa");
            parsed.UserName.ShouldEqual("Copa");
            parsed.Password.ShouldEqual("abc_xyz");
            parsed.Port.ShouldEqual(12345);
            parsed.RequestedHeartbeat.ShouldEqual(3);
        }
コード例 #8
0
        public void SetUp()
        {
            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var connection = MockRepository.GenerateStub<IPersistentConnection>();
            var channelFactory = MockRepository.GenerateStub<IPersistentChannelFactory>();
            channel = MockRepository.GenerateStub<IPersistentChannel>();

            channelFactory.Stub(x => x.CreatePersistentChannel(connection)).Return(channel);
            channel.Stub(x => x.InvokeChannelAction(null)).IgnoreArguments().WhenCalled(
                x => ((Action<IModel>)x.Arguments[0])(null));

            dispatcher = new ClientCommandDispatcher(configuration, connection, channelFactory);

        }
コード例 #9
0
ファイル: RabbitHutch.cs プロジェクト: nslowes/EasyNetQ
        /// <summary>
        /// Creates a new instance of RabbitBus.
        /// </summary>
        /// <param name="connectionString">
        /// The EasyNetQ connection string. Example:
        /// host=192.168.1.1;port=5672;virtualHost=MyVirtualHost;username=MyUsername;password=MyPassword;requestedHeartbeat=10
        /// 
        /// The following default values will be used if not specified:
        /// host=localhost;port=5672;virtualHost=/;username=guest;password=guest;requestedHeartbeat=0
        /// </param>
        /// <param name="registerServices">
        /// Override default services. For example, to override the default IEasyNetQLogger:
        /// RabbitHutch.CreateBus("host=localhost", x => x.Register&lt;IEasyNetQLogger&gt;(_ => myLogger));
        /// </param>
        /// <returns>
        /// A new RabbitBus instance.
        /// </returns>
        public static IBus CreateBus(string connectionString, Action<IServiceRegister> registerServices)
        {
            if(connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if(registerServices == null)
            {
                throw new ArgumentNullException("registerServices");
            }

            var connectionStringParser = new ConnectionStringParser();

            var connectionConfiguration = connectionStringParser.Parse(connectionString);

            return CreateBus(connectionConfiguration, registerServices);
        }
コード例 #10
0
ファイル: ENQUtils.cs プロジェクト: c0d3m0nky/mty
        public static IBus GetBus(string virtualHost = "")
        {
            IBus bus;

            if (Busses.ContainsKey(virtualHost))
            {
                bus = Busses[virtualHost];
            }
            else
            {
                var conn = new ConnectionStringParser().Parse(RabbitConn);

                conn.VirtualHost = virtualHost;

                bus = RabbitHutch.CreateBus(conn.ToString());

                Busses.Add(virtualHost, bus);    
            }

            return bus;
        }
コード例 #11
0
 public void SetUp()
 {
     connectionStringParser = new ConnectionStringParser();
 }