Exemplo n.º 1
0
        static EventStoreHelper()
        {
            var settings = CommonHelper.GetConfig().GetSection("eventStore");

            var userCredentials = new ReactiveDomain.UserCredentials(
                username: settings["ESUserId"],
                password: settings["ESPassword"]);

            var eventStoreLoader = new EventStoreLoader();

            eventStoreLoader.Connect(
                credentials: userCredentials,
                server: IPAddress.Parse(settings["ESipAddress"]),
                tcpPort: int.Parse(settings["ESTcpPort"]));

            var streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder(Constants.DomainPrefix);

            GetListener = name => new StreamListener(
                listenerName: name,
                eventStoreConnection: eventStoreLoader.Connection,
                streamNameBuilder: streamNameBuilder,
                serializer: new JsonMessageSerializer());

            GetRepository = () => new StreamStoreRepository(
                streamNameBuilder: streamNameBuilder,
                eventStoreConnection: eventStoreLoader.Connection,
                eventSerializer: new JsonMessageSerializer());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Setup EventStore");
            EventStoreLoader.SetupEventStore();

            ActorSystem.Create("ras").WhenTerminated.Wait();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            EventStoreLoader.SetupEventStore(EventStoreLoader.StartConflictOption.Connect);
            var connection = EventStoreLoader.Connection;

            var bus   = new FakeBus();
            var queue = new ReadmodelPublisher();



            var orderCreatedHandler = new CreateOrderCommandHandler(
                new Repository <Order>(
                    new Disruptor.ReadModel.Tests.Infrastructure.EventStore(connection, queue)));
            var orderItemAddedHandler = new AddItemToOrderCommandHandler(
                new Repository <Order>(
                    new Disruptor.ReadModel.Tests.Infrastructure.EventStore(connection, queue)));

            bus.RegisterAsyncHandler <CreateOrderCommand>(orderCreatedHandler.HandleAsync);
            bus.RegisterAsyncHandler <AddItemToCardCommand>(orderItemAddedHandler.HandleAsync);


            TestSendCommandAndFillupReadmodel(queue, bus);

            EventStoreLoader.TeardownEventStore(false, true);
        }
Exemplo n.º 4
0
        public GetEventStoreRepositoryIntegrationTests()
        {
            var es = new EventStoreLoader();

            es.SetupEventStore(new DirectoryInfo(@"C:\Program Files\PerkinElmer\Greylock\EventStore"));
            _connection = EventStoreConnection.Create(IntegrationTestTcpEndPoint);
            _connection.ConnectAsync().Wait();
            _repo = new ReactiveDomain.EventStore.GetEventStoreRepository(_connection);
        }
Exemplo n.º 5
0
        public static void Configure(IGeneralBus bus)
        {
            _es = new EventStoreLoader();
            _es.SetupEventStore(new DirectoryInfo(@"C:\Users\rosed18169\source\EventStore-OSS-Win-v3.9.4"));
            _esConnection = _es.Connection;
            _esRepository = new GetEventStoreRepository(_es.Connection);
            Locator.CurrentMutable.RegisterConstant(_esRepository, typeof(IRepository));

            _acctSvc = new AccountSvc(bus, _esRepository);
        }
        protected override void Given()
        {
            TcpEndPointConnection = EventStoreConnection.Create(IntegrationTestTcpEndPoint);
            EventStore            = new EventStoreLoader();

            TcpEndPointConnection.ConnectAsync().Wait();

            //TODO: better path!  Tacky because PerkinElmer\Greylock...
            EventStore.SetupEventStore(
                new DirectoryInfo(
                    @"c:\program files\PerkinElmer\Greylock\eventStore"));

            Repo = new GetEventStoreRepository(EventStore.Connection);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            EventStoreLoader.SetupEventStore();
            var eventReader = new EventReader("Payments");
            var eventWriter = new EventWriter("CounterResults");

            eventReader.ConnectToPersistentSubscription("Payments", "Payments_Counter", (_, e) =>
            {
                var data = Encoding.ASCII.GetString(e.Event.Data);
                switch (e.Event.EventType)
                {
                case "PaymentStatusChanged":
                    var pscmessage    = data.ParseJson <PaymentStatusChangedMessage>();
                    var calculator    = new CustomerPaymentCounterCalculator();
                    var result        = calculator.GetPaymentChanges(pscmessage);
                    var eReader1      = new EventReader($"evt-{pscmessage.Payment.PaymentReference}");
                    var allMessages   = eReader1.ReadAllMessages(pscmessage.Payment.PaymentReference);
                    var counterResult = new CounterResult {
                        CustomerReference = pscmessage.Customer.CustomerReference, PaymentReference = pscmessage.Payment.PaymentReference, Increment = result
                    };
                    eventWriter.WriteEvent(counterResult.AsJsonString(), "IncrementCalculated");
                    Console.WriteLine($"**Event received for payment {pscmessage.Payment.PaymentReference}");
                    break;

                case "ApprovalStatusChanged":
                    var asmessage = data.ParseJson <PaymentApprovalStatusChangedMessage>();
                    break;

                case "CustomerAccountChanged":
                    var camessage = data.ParseJson <PaymentCustomerAccountChangedMessage>();
                    break;

                case "WithdrawalChannelChanged":
                    var wcmessage = data.ParseJson <WithdrawalChannelChangedMessage>();
                    break;

                default:
                    Console.WriteLine("Cannot parse event type");
                    return;
                }
            });

            Console.ReadLine();
        }
Exemplo n.º 8
0
        private void ConnectToLiveES()
        {
            var userCredentials = new ReactiveDomain.UserCredentials(username: "******", password: "******");

            var eventStoreLoader = new EventStoreLoader();

            eventStoreLoader.Connect(
                credentials: userCredentials,
                server: IPAddress.Parse("127.0.0.1"),
                tcpPort: 1113);

            Connection = eventStoreLoader.Connection;

            // ReSharper disable once PossibleNullReferenceException
            _connection = (IEventStoreConnection)typeof(EventStoreConnectionWrapper)
                          .GetField("_conn", BindingFlags.NonPublic | BindingFlags.Instance)
                          .GetValue(eventStoreLoader.Connection);

            log.Info("Connected to ES");
        }