public ITransport Create(string inputQueueAddress)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory);

            if (inputQueueAddress == null)
            {
                var transport = new AzureServiceBusTransport(ConnectionString, null, consoleLoggerFactory, asyncTaskFactory);

                transport.Initialize();

                return transport;
            }

            return _queuesToDelete.GetOrAdd(inputQueueAddress, () =>
            {
                var transport = new AzureServiceBusTransport(ConnectionString, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory);

                transport.PurgeInputQueue();

                transport.Initialize();

                return transport;
            });
        }
 public IDataBusStorage Create()
 {
     var consoleLoggerFactory = new ConsoleLoggerFactory(false);
     var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
     var sqlServerDataBusStorage = new SqlServerDataBusStorage(connectionProvider, "databus", true, consoleLoggerFactory);
     sqlServerDataBusStorage.Initialize();
     return sqlServerDataBusStorage;
 }
Esempio n. 3
0
            public ConsoleLogger(Type type, LoggingColors loggingColors, ConsoleLoggerFactory factory, bool showTimestamps)
            {
                this.type          = type;
                this.loggingColors = loggingColors;
                this.factory       = factory;

                logLineFormatString = showTimestamps
                                          ? "{0} {1} {2} ({3}): {4}"
                                          : "{1} {2} ({3}): {4}";
            }
        public ISubscriptionStorage Create()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(true);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            var storage = new SqlServerSubscriptionStorage(connectionProvider, TableName, true, consoleLoggerFactory);

            storage.EnsureTableIsCreated();
            
            return storage;
        }
        public ISagaSnapshotStorage Create()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(true);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);

            var snapperino = new SqlServerSagaSnapshotStorage(connectionProvider, TableName, consoleLoggerFactory);

            snapperino.EnsureTableIsCreated();

            return snapperino;
        }
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            var tableName = TestConfig.QueueName("data");

            SqlTestHelper.DropTable(tableName);

            _storage = new SqlServerDataBusStorage(connectionProvider, tableName, true, loggerFactory);
            _storage.Initialize();
        }
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);
            _connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            _dataTableName = TestConfig.QueueName("sagas");
            _indexTableName = TestConfig.QueueName("sagaindex");

            SqlTestHelper.DropTable(_indexTableName);
            SqlTestHelper.DropTable(_dataTableName);

            _storage = new SqlServerSagaStorage(_connectionProvider, _dataTableName, _indexTableName, loggerFactory);
        }
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(_tableName);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            _transport = new SqlServerTransport(connectionProvider, _tableName, QueueName, consoleLoggerFactory);
            _transport.EnsureTableIsCreated();

            Using(_transport);

            _transport.Initialize();
        }
Esempio n. 9
0
        static AmazonSqsTransport CreateTransport(string inputQueueAddress, TimeSpan peeklockDuration)
        {
            var region = RegionEndpoint.GetBySystemName(ConnectionInfo.RegionEndpoint);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport = new AmazonSqsTransport(inputQueueAddress, ConnectionInfo.AccessKeyId, ConnectionInfo.SecretAccessKey,
                region,
                consoleLoggerFactory,
                new TplAsyncTaskFactory(consoleLoggerFactory));

            transport.Initialize(peeklockDuration);
            transport.Purge();
            return transport;
        }
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            var dataTableName = TestConfig.QueueName("sagas");
            var indexTableName = TestConfig.QueueName("sagaindex");

            SqlTestHelper.DropTable(indexTableName);
            SqlTestHelper.DropTable(dataTableName);

            _storage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, loggerFactory);

            _storage.EnsureTablesAreCreated();
        }
Esempio n. 11
0
        protected override void SetUp()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory);
            new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, consoleLoggerFactory, asyncTaskFactory).PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName))
                .Options(o =>
                {
                    o.LogPipeline();
                })
                .Start();

            Using(_bus);
        }
        protected override void SetUp()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            _transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory));
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, _azureServiceBusMode)
                .AutomaticallyRenewPeekLock())
                .Options(o =>
                {
                    o.SetNumberOfWorkers(1);
                    o.SetMaxParallelism(1);
                })
                .Start();

            Using(_bus);
        }
Esempio n. 13
0
            public ConsoleLogger(Type type, LoggingColors loggingColors, ConsoleLoggerFactory factory, bool showTimestamps)
            {
                _type = type;
                _loggingColors = loggingColors;
                _factory = factory;

                _logLineFormatString = showTimestamps
                                          ? "{0} {1} {2} ({3}): {4}"
                                          : "{1} {2} ({3}): {4}";
            }
Esempio n. 14
0
 public ConsoleLogger(Type type, LoggingColors loggingColors, ConsoleLoggerFactory factory)
 {
     this.type          = type;
     this.loggingColors = loggingColors;
     this.factory       = factory;
 }
Esempio n. 15
0
 public ConsoleLogger(Type type, LoggingColors loggingColors, ConsoleLoggerFactory factory)
 {
     this.type = type;
     this.loggingColors = loggingColors;
     this.factory = factory;
 }
        ITransport GetTransport()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString = StandardAzureServiceBusTransportFactory.ConnectionString;
            var busLifetimeEvents = new BusLifetimeEvents();

            if (_mode == AzureServiceBusMode.Basic)
            {
                var basicTransport = new BasicAzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory, busLifetimeEvents);
                Using(basicTransport);
                basicTransport.Initialize();
                basicTransport.PurgeInputQueue();
                return basicTransport;
            }
            var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory, busLifetimeEvents);
            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();
            return transport;
        }
        public async void ShouldBeAbleToRecieveEvenWhenNotCreatingQueue(AzureServiceBusMode mode)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new BusLifetimeEvents());
            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var recieverActivator = new BuiltinHandlerActivator();
            var senderActivator = new BuiltinHandlerActivator();

            var receiverBus = Configure.With(recieverActivator)
                .Logging(l => l.ColoredConsole())
                .Transport(t =>
                    t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName)
                        .DoNotCreateQueues())
                .Start();

            var senderBus = Configure.With(senderActivator)
                .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, "sender", mode))
                .Start();

            Using(receiverBus);
            Using(senderBus);

            var gotMessage = new ManualResetEvent(false);

            recieverActivator.Handle<string>(async (bus, context, message) =>
            {
                gotMessage.Set();
                Console.WriteLine("got message in readonly mode");
            });
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");

            gotMessage.WaitOrDie(TimeSpan.FromSeconds(10));


        }
        public async void DoesntIgnoreDefinedTimeoutWhenReceiving(AzureServiceBusMode mode, int operationTimeoutInSeconds)
        {
            var operationTimeout = TimeSpan.FromSeconds(operationTimeoutInSeconds);

            var connString = StandardAzureServiceBusTransportFactory.ConnectionString;
            var builder = new ServiceBusConnectionStringBuilder(connString)
            {
                OperationTimeout = operationTimeout
            };
            var newConnString = builder.ToString();

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport = new AzureServiceBusTransport(newConnString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new BusLifetimeEvents());

            Using(transport);

            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var senderActivator = new BuiltinHandlerActivator();

            var senderBus = Configure.With(senderActivator)
                .Transport(t => t.UseAzureServiceBus(newConnString, "sender", mode))
                .Start();

            Using(senderBus);

            // queue 3 messages
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver2");
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver3");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 1
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 2
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 3
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 4 - NOTHING
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }

            // put 1 more message 
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver5");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 5
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 6 - NOTHING
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }
        }