我正在使用EventStoreDB V20,并且正在尝试在我的本地开发机器上设置一个持久订阅。在仪表板上,我可以看到列出了持久订阅,但从未调用过处理程序。
我正在使用这些小玩意儿: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从未被调用过。我需要改变什么?
发布于 2021-01-15 19:50:03
一切似乎都设置正确,但我怀疑您是否有名为all的流。如果您正在尝试为$all流创建持久订阅,则不可能实现。您只能对$all流进行追加订阅。
https://stackoverflow.com/questions/65374552
复制相似问题