【发布时间】:2016-03-06 14:33:41
【问题描述】:
作为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 事件:
我是否误解了订阅、信息流和群组的工作方式?请赐教。
【问题讨论】:
标签: c# cqrs event-sourcing eventstoredb