public when_using_listener_start_with_custom_stream_synched_bus(StreamStoreConnectionFixture fixture)
        {
            conn = fixture.Connection;
            conn.Connect();

            // Build an origin stream from strings to which the the events are appended
            var originStreamName = $"testStream-{Guid.NewGuid():N}";

            var result = fixture.Connection.AppendToStream(
                originStreamName,
                ExpectedVersion.NoStream,
                null,
                _eventSerializer.Serialize(new TestEvent()));

            Assert.True(result.NextExpectedVersion == 0);

            // Wait for the stream to be written
            CommonHelpers.WaitForStream(conn, originStreamName);

            listener = new QueuedStreamListener(
                originStreamName,
                fixture.Connection,
                new PrefixedCamelCaseStreamNameBuilder(),
                _eventSerializer,
                "BUS_NAME",
                LiveProcessingStarted);
            SubscriptionDisposer = listener.EventStream.Subscribe(new AdHocHandler <Event>(Handle));
            listener.Start(originStreamName);
        }
Пример #2
0
        public when_using_snapshot_read_model(StreamStoreConnectionFixture fixture)
        {
            _conn = fixture.Connection;
            _conn.Connect();

            _aggId  = Guid.NewGuid();
            _stream = _namer.GenerateForAggregate(typeof(SnapReadModelTestAggregate), _aggId);

            AppendEvents(10, _conn, _stream, 2);
        }
Пример #3
0
        public when_using_read_model_base(StreamStoreConnectionFixture fixture)
            : base(nameof(when_using_read_model_base), GetListener)
        {
            //_conn = new MockStreamStoreConnection("mockStore");
            _conn = fixture.Connection;
            _conn.Connect();

            // ReSharper disable once RedundantTypeArgumentsOfMethod
            EventStream.Subscribe <ReadModelTestEvent>(this);

            _stream1 = Namer.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());
            _stream2 = Namer.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());

            AppendEvents(10, _conn, _stream1, 2);
            AppendEvents(10, _conn, _stream2, 3);
        }
Пример #4
0
        public when_using_read_model_base_with_reader(StreamStoreConnectionFixture fixture)
            : base(nameof(when_using_read_model_base),
                   new ConfiguredConnection(fixture.Connection, Namer, Serializer))
        {
            _conn = fixture.Connection;
            _conn.Connect();

            // ReSharper disable once RedundantTypeArgumentsOfMethod
            EventStream.Subscribe <ReadModelTestEvent>(this);

            _stream1 = Namer.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());
            _stream2 = Namer.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());

            AppendEvents(10, _conn, _stream1, 2);
            AppendEvents(10, _conn, _stream2, 3);
            _conn.TryConfirmStream(_stream1, 10);
            _conn.TryConfirmStream(_stream2, 10);
            _conn.TryConfirmStream(Namer.GenerateForCategory(typeof(TestAggregate)), 20);
        }
Пример #5
0
        public void Connect(
            UserCredentials credentials,
            IPAddress server,
            int tcpPort)
        {
            var tcpEndpoint = new IPEndPoint(server, tcpPort);

            var settings = ConnectionSettings.Create()
                           .SetDefaultUserCredentials(new global::EventStore.ClientAPI.SystemData.UserCredentials(credentials.Username, credentials.Password))
                           .KeepReconnecting()
                           .KeepRetrying()
                           .UseConsoleLogger()
                           //.EnableVerboseLogging()
                           .Build();

            Connection = new EventStoreConnectionWrapper(EventStoreConnection.Create(settings, tcpEndpoint, "Default Connection"));

            if (Connection == null)
            {
                _log.Error("EventStore Connection is null - Diagnostic Monitoring will be unavailable.");
                TeardownEventStore(false);
                return;
            }
            Connection.Connect();
            int retry = 8;
            int count = 0;

            do
            {
                try {
                    Connection.ReadStreamForward("by_event_type", 0, 1);
                    return;
                }
                catch {
                    //ignore
                }
                Thread.Sleep(100);
                count++;
            } while (count < retry);
            throw new Exception("Unable to start Eventstore");
        }