【发布时间】:2021-01-15 19:50:02
【问题描述】:
我正在使用 EventStoreDB V20,并尝试在本地开发机器上设置持久订阅。在仪表板上,我可以看到列出的持久订阅,但处理程序从未被调用。
我正在使用这些 nugets: https://www.nuget.org/packages/EventStore.Client.Grpc/ https://www.nuget.org/packages/EventStore.Client.Grpc.PersistentSubscriptions/20.10.0
我在 docker 中运行 EventStore:
docker run --name esdb-node -it -p 2113:2113 -p 1113:1113 -e EVENTSTORE_DEV=true eventstore/eventstore:latest --insecure --run-projections=All --enable-atom-pub-over-http
为了附加事件,我这样做:
await eventStoreClient.AppendToStreamAsync(
aggregate.Id.ToString(),
aggregate.Version == 0 ? StreamRevision.None : StreamRevision.FromInt64(aggregate.Version), events);
创建和订阅持久订阅:
var client = new EventStorePersistentSubscriptionsClient(new EventStoreClientSettings {
CreateHttpMessageHandler = () =>
new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
(message, certificate2, x509Chain, sslPolicyErrors) => true // ignore https
},
ConnectivitySettings = new EventStoreClientConnectivitySettings
{
Address = new Uri("http://127.0.0.1:2113?Tls=false&TlsVerifyCert=false")
}});
await client.CreateAsync("all", "TestGroup", new PersistentSubscriptionSettings(startFrom: StreamPosition.End));
await SubscribeAsync(client);
Console.ReadLine();
}
private static Task<PersistentSubscription> SubscribeAsync(EventStorePersistentSubscriptionsClient client)
{
return client.SubscribeAsync("all", "TestGroup",
(subscription, evt, retryCount, cancelToken) =>
{
Console.WriteLine("Received: " + Encoding.UTF8.GetString(evt.Event.Data.Span));
return Task.CompletedTask;
});
}
Console.WriteLine 永远不会被调用。我需要改变什么?
【问题讨论】:
-
你有名为
all的流吗? -
不,我真的想要$all
标签: c# event-sourcing eventstoredb