订阅类别流,事件永远不会出现在订阅客户端

Subscribe to category stream, event never appears in subscription client

作为 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。在我的活动商店的管理面板中,我可以在竞争消费者选项卡上看到与此 stream/group 的连接:

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

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

这里的答案是事件存储的预测被禁用。

使用 --run-projections=all

开始商店