Represents a persistent subscription connection.
 protected override void When()
 {
     _conn.CreatePersistentSubscriptionAsync(_stream, "agroupname17", _settings, DefaultData.AdminCredentials).Wait();
     _sub = _conn.ConnectToPersistentSubscription(_stream,
         "agroupname17",
         (sub, e) => Console.Write("appeared"),
         (sub, reason, ex) => {});
 }
 private static void EventAppeared(EventStorePersistentSubscriptionBase eventStorePersistentSubscriptionBase,
     ResolvedEvent resolvedEvent)
 {
    ;
     var data = Encoding.ASCII.GetString(resolvedEvent.Event.Data);
     Console.WriteLine("Received: " + resolvedEvent.Event.EventStreamId + ":" + resolvedEvent.Event.EventNumber);
     Console.WriteLine(data);
 }
        private void ConnectToSubscription()
        {
            var bufferSize = 10;
            var autoAck = true;

            _subscription = _conn.ConnectToPersistentSubscription(STREAM, GROUP, EventAppeared, SubscriptionDropped,
                User, bufferSize, autoAck);
        }
 public async Task PublishAsync(EventStorePersistentSubscriptionBase subscription, ResolvedEvent resolvedEvent) {
   try {
     object eventObject = resolvedEvent.Event.ToEventObject();
     using (Container.BeginExecutionContextScope()) {
       dynamic publisher = Container.GetInstance<IPublishEvent>();
       await publisher.PublishAsync((dynamic)eventObject).ConfigureAwait(true);
     }
     subscription.Acknowledge(resolvedEvent);
   } catch (Exception ex) {
     subscription.Fail(resolvedEvent, PersistentSubscriptionNakEventAction.Unknown, ex.Message);
   }
 }
Exemplo n.º 5
0
        protected override void Given()
        {
            _conn = EventStoreConnection.Create(_node.TcpEndPoint.ToESTcpUri());
            _conn.ConnectAsync().Wait();
            _conn.CreatePersistentSubscriptionAsync(_streamName, _groupName, _settings,
                    DefaultData.AdminCredentials).Wait();
            _sub1 = _conn.ConnectToPersistentSubscription(_streamName,_groupName,
                        (subscription, @event) => Console.WriteLine(), 
                        (subscription, reason, arg3) => Console.WriteLine());
            _sub2 = _conn.ConnectToPersistentSubscription(_streamName, _groupName,
                        (subscription, @event) => Console.WriteLine(),
                        (subscription, reason, arg3) => Console.WriteLine(),
                        DefaultData.AdminCredentials);

        }
Exemplo n.º 6
0
        protected override void Given()
        {
            base.Given();
            _conn.CreatePersistentSubscriptionAsync(_streamName, "secondgroup", _settings,
                        DefaultData.AdminCredentials).Wait();
            _sub3 = _conn.ConnectToPersistentSubscription(_streamName,"secondgroup",
                        (subscription, @event) => Console.WriteLine(),
                        (subscription, reason, arg3) => Console.WriteLine());
            _sub4 = _conn.ConnectToPersistentSubscription(_streamName,"secondgroup",
                        (subscription, @event) => Console.WriteLine(),
                        (subscription, reason, arg3) => Console.WriteLine(),
                        DefaultData.AdminCredentials);
            _sub5 = _conn.ConnectToPersistentSubscription(_streamName,"secondgroup",
                        (subscription, @event) => Console.WriteLine(),
                        (subscription, reason, arg3) => Console.WriteLine(),
                        DefaultData.AdminCredentials);

        }
 private void HandleEvent(EventStorePersistentSubscriptionBase sub, ResolvedEvent resolvedEvent)
 {
     if (_set) return;
     _set = true;
     _firstEvent = resolvedEvent;
     _resetEvent.Set();
 }
 private void HandleEvent(EventStorePersistentSubscriptionBase sub, ResolvedEvent resolvedEvent)
 {
     _firstEvent = resolvedEvent;
     _resetEvent.Set();
 }
 private static void HandleEvent(EventStorePersistentSubscriptionBase sub, ResolvedEvent resolvedEvent)
 {
     throw new Exception("test");
 }
 private void Dropped(EventStorePersistentSubscriptionBase sub, SubscriptionDropReason reason, Exception exception)
 {
     _exception = exception;
     _reason = reason;
     _resetEvent.Set();
 }
Exemplo n.º 11
0
 private async void EventAppeared(EventStorePersistentSubscriptionBase subscription, ResolvedEvent resolvedEvent) {
   await Publisher.PublishAsync(subscription, resolvedEvent);
 }
Exemplo n.º 12
0
 private async void SubscriptionDropped(EventStorePersistentSubscriptionBase subscription, SubscriptionDropReason reason, Exception ex) {
   await ConnectSubscription();
 }
Exemplo n.º 13
0
 private async Task ConnectSubscription() {
   IEventStoreConnection connection = await ConnectionProvider.GetConnectionAsync();
   Subscription = connection.ConnectToPersistentSubscription(StreamName, GroupName,
     EventAppeared, SubscriptionDropped, userCredentials: new UserCredentials("admin", "changeit"), bufferSize: 10, autoAck: false);
 }
 private void SubscriptionDropped(EventStorePersistentSubscriptionBase eventStorePersistentSubscriptionBase,
     SubscriptionDropReason subscriptionDropReason, Exception ex)
 {
     ConnectToSubscription();
 }
 protected override void Given()
 {
     base.Given();
     _conn.CreatePersistentSubscriptionAsync(_stream, _group, _settings,
         DefaultData.AdminCredentials).Wait();
     // First connection
     _firstConn = _conn.ConnectToPersistentSubscriptionAsync(
         _stream,
         _group,
         (s, e) => s.Acknowledge(e),
         (sub, reason, ex) => { },
         DefaultData.AdminCredentials).Result;
 }