5

作为GetEventStore的第一次用户并阅读了文档后,我遇到了一个问题,即事件从未出现在我的订阅客户端上。

这是可能的,因为我错过了一个配置步骤。

拥有此控制台应用程序客户端:

public class EventStoreSubscriptionClient : ISubscriptionClient
{
    private const string GroupName = "liner";
    private const string StreamName = "$ce-happening";

    private readonly IProvideEventStoreConnection _eventStoreConnection;
    private readonly UserCredentials _userCredentials;

    private EventStorePersistentSubscriptionBase EventStorePersistentSubscriptionBase { get; set; }

    public EventStoreSubscriptionClient(IProvideEventStoreConnection eventStoreConnection, UserCredentials userCredentials)
    {
        _eventStoreConnection = eventStoreConnection;
        _userCredentials = userCredentials;
    }

    public void Connect()
    {
        var connection = _eventStoreConnection.ConnectAsync().Result;
        EventStorePersistentSubscriptionBase = connection.ConnectToPersistentSubscription(
               StreamName,
               GroupName,
               EventAppeared,
               SubscriptionDropped,
               _userCredentials,
               10,
               false
        );
    }

    private void SubscriptionDropped(EventStorePersistentSubscriptionBase subscription, SubscriptionDropReason reason, Exception ex)
    {
        Connect();
    }

    private async void EventAppeared(EventStorePersistentSubscriptionBase subscription, ResolvedEvent resolvedEvent)
    {
        Console.WriteLine("Event appeared: " + resolvedEvent.Event.EventId);
    }

    public void Dispose()
    {
        EventStorePersistentSubscriptionBase.Stop(TimeSpan.FromSeconds(15));
    }
}

启动此控制台应用程序后,与http://myserver:1113的连接正常。在我的活动商店的管理面板中,我可以在竞争消费者选项卡上看到与此流/组的连接:

事件存储管理的图像

但是,如果我发送一个类似的事件,happening-<guid>它会显示在流浏览器上,但我的订阅客户端永远不会收到event appeared事件:

事件存储接收事件的图像

我是否误解了订阅、流和组的工作方式?请赐教。

4

1 回答 1

6

这里的答案是 Event Store 的预测被禁用。

开店--run-projections=all

于 2016-03-08T07:35:05.273 回答