Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoDatabase"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MongoDatabase(MongoConfiguration configuration)
     : this(configuration,
            ConnectionFactoryFactory.GetConnection(configuration.ConnectionString),
            new MongoConnectionStringBuilder(configuration.ConnectionString).Database)
 {
     //Todo: Add check for null
 }
 public void TestExceptionWhenMinimumPoolSizeIsGreaterThenMaximumPoolSize()
 {
     try{
         ConnectionFactoryFactory.GetConnection("MinimumPoolSize=50; MaximumPoolSize=10");
     }catch (ArgumentException) {
     }catch (Exception) {
         Assert.Fail("Wrong exception thrown");
     }
 }
 public void TestCreatePoolForEachUniqeConnectionString()
 {
     ConnectionFactoryFactory.GetConnection(string.Empty);
     ConnectionFactoryFactory.GetConnection(string.Empty);
     ConnectionFactoryFactory.GetConnection("Username=test");
     ConnectionFactoryFactory.GetConnection("Username=test");
     ConnectionFactoryFactory.GetConnection("Server=localhost");
     Assert.AreEqual(3, ConnectionFactoryFactory.PoolCount);
 }
        public void TestGetConnection()
        {
            var connection1 = ConnectionFactoryFactory.GetConnection(string.Empty);
            var connection2 = ConnectionFactoryFactory.GetConnection(string.Empty);

            Assert.IsNotNull(connection1);
            Assert.IsNotNull(connection2);
            Assert.AreEqual(1, ConnectionFactoryFactory.PoolCount);
        }
        public void TestTearDown()
        {
            using (var mongo = ConnectAndAuthenticatedMongo(AdminUser, AdminPass))
            {
                mongo[TestDatabaseName].Metadata.RemoveUser(TestUser);
                mongo["admin"].Metadata.RemoveUser(AdminUser);
            }

            // clean connections
            ConnectionFactoryFactory.Shutdown();
        }
Esempio n. 6
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "Mongo" /> class.
        /// </summary>
        /// <param name = "configuration">The mongo configuration.</param>
        public Mongo(MongoConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            configuration.ValidateAndSeal();

            _configuration = configuration;
            _connection    = ConnectionFactoryFactory.GetConnection(configuration.ConnectionString);
        }
Esempio n. 7
0
        public void TestSendQueryMessage()
        {
            //Connection conn = new Connection("10.141.153.2");
            var conn = ConnectionFactoryFactory.GetConnection(string.Empty);

            conn.Open();

            var qmsg = GenerateQueryMessage();

            conn.SendTwoWayMessage(qmsg, string.Empty);

            conn.Close();
        }
Esempio n. 8
0
        /// <summary>
        ///     Registers the default EasyNetQ components
        /// </summary>
        /// <param name="serviceRegister">The register</param>
        public static void RegisterDefaultServices(this IServiceRegister serviceRegister)
        {
            Preconditions.CheckNotNull(serviceRegister, "container");

            // Note: IConnectionConfiguration gets registered when RabbitHutch.CreateBus(..) is run.
            // default service registration
            serviceRegister
            .Register <IConnectionStringParser, ConnectionStringParser>()
            .Register <ISerializer>(_ => new JsonSerializer())
            .Register <IConventions, Conventions>()
            .Register <IEventBus, EventBus>()
            .Register <ITypeNameSerializer, DefaultTypeNameSerializer>()
            .Register <ICorrelationIdGenerationStrategy, DefaultCorrelationIdGenerationStrategy>()
            .Register <IMessageSerializationStrategy, DefaultMessageSerializationStrategy>()
            .Register <IMessageDeliveryModeStrategy, MessageDeliveryModeStrategy>()
            .Register(new AdvancedBusEventHandlers())
            .Register <IProduceConsumeInterceptor, DefaultInterceptor>()
            .Register <IConsumerDispatcherFactory, ConsumerDispatcherFactory>()
            .Register <IExchangeDeclareStrategy, DefaultExchangeDeclareStrategy>()
            .Register <IConsumerErrorStrategy, DefaultConsumerErrorStrategy>()
            .Register <IErrorMessageSerializer, DefaultErrorMessageSerializer>()
            .Register <IHandlerRunner, HandlerRunner>()
            .Register <IInternalConsumerFactory, InternalConsumerFactory>()
            .Register <IConsumerFactory, ConsumerFactory>()
            .Register(c =>
            {
                var connectionConfiguration = c.Resolve <ConnectionConfiguration>();
                return(ConnectionFactoryFactory.CreateConnectionFactory(connectionConfiguration));
            })
            .Register <IClientCommandDispatcher, SingleChannelClientCommandDispatcher>()
            .Register <IPersistentConnection, PersistentConnection>()
            .Register <IPersistentChannelFactory, PersistentChannelFactory>()
            .Register <IPublishConfirmationListener, PublishConfirmationListener>()
            .Register <IHandlerCollectionFactory, HandlerCollectionFactory>()
            .Register <IPullingConsumerFactory, PullingConsumerFactory>()
            .Register <IAdvancedBus, RabbitAdvancedBus>()
            .Register <IPubSub, DefaultPubSub>()
            .Register <IRpc, DefaultRpc>()
            .Register <ISendReceive, DefaultSendReceive>()
            .Register <IScheduler>(
                x => new DeadLetterExchangeAndMessageTtlScheduler(
                    x.Resolve <ConnectionConfiguration>(),
                    x.Resolve <IAdvancedBus>(),
                    x.Resolve <IConventions>(),
                    x.Resolve <IMessageDeliveryModeStrategy>(),
                    x.Resolve <IExchangeDeclareStrategy>()
                    )
                )
            .Register <IBus, RabbitBus>();
        }
Esempio n. 9
0
        public void TestReconnectOnce()
        {
            var conn = ConnectionFactoryFactory.GetConnection(string.Empty);

            conn.Open();

            WriteBadMessage(conn);
            try
            {
                var qmsg = GenerateQueryMessage();
                conn.SendTwoWayMessage(qmsg, string.Empty);
            }
            catch (IOException)
            {
                //Should be able to resend.
                Assert.IsTrue(conn.IsConnected);
                var qmsg = GenerateQueryMessage();
                var rmsg = conn.SendTwoWayMessage(qmsg, string.Empty);
                Assert.IsNotNull(rmsg);
            }
        }
 public void SetUp()
 {
     ConnectionFactoryFactory.Shutdown();
 }
Esempio n. 11
0
 public void TearDown()
 {
     ConnectionFactoryFactory.Shutdown();
 }