简体   繁体   English

Akka.Net PersistenceQuery不返回所有结果

[英]Akka.Net PersistenceQuery not returning all results

I am using Akka.Net (v 1.3.2) and am trying to query the event journal for all events with a specific tag. 我正在使用Akka.Net(v 1.3.2),并试图在事件日志中查询具有特定标记的所有事件。 I only want the events that exist at the time I query the journal. 我只想查询期刊时存在的事件。 Inside an actor, I have the following code: 在演员内部,我有以下代码:

var readJournal = PersistenceQuery.Get(Context.System).ReadJournalFor<SqlReadJournal>(SqlReadJournal.Identifier);
var stream = readJournal.CurrentEventsByTag("The Tag Name", Offset.NoOffset());
var materializer = ActorMaterializer.Create(Context.System);

stream.RunForeach(envelope =>
{
    // Do some stuff with the EventEnvelope
}, materializer).Wait();

This will successfully query the event journal. 这将成功查询事件日志。 However, the problem is it will only return the first 100 events. 但是,问题在于它只会返回前100个事件。 I need all of them that match the query! 我需要所有与查询匹配的东西!

Question: How do I remove the limit/filter that exists when querying the event journal by tag name? 问题:如何删除通过标签名称查询事件日志时存在的限制/过滤器?

If you need it, here is my akka.persistence configuration: 如果需要,这是我的akka​​.persistence配置:

var config = Akka.Configuration.ConfigurationFactory.ParseString(@"
    akka.persistence {
        journal {
            plugin = ""akka.persistence.journal.sql-server""
            sql-server {
                class = ""Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer""
                connection-string = """ + connectionString + @"""
                schema-name = dbo
                table-name = __akka_EventJournal
                metadata-table-name = __akka_Metadata
                auto-initialize = on
            }
        }

        snapshot-store {
            plugin = ""akka.persistence.snapshot-store.sql-server""
            sql-server {
                class = ""Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer""
                connection-string = """ + connectionString + @"""
                schema-name = dbo
                table-name = __akka_SnapshotStore
                auto-initialize = on
            }
        }
    }"
);

There are two things to check out: 有两件事要检查:

  1. You can set the maximum number of messages returned in one query by setting up akka.persistence.query.journal.sql.max-buffer-size value (see: reference.conf ). 您可以通过设置akka.persistence.query.journal.sql.max-buffer-size值(请参阅: reference.conf )来设置在一个查询中返回的最大消息数。
  2. Use readJournal.EventsByTag instead of readJournal.CurrentEventsByTag to get a continuous stream of events. 使用readJournal.EventsByTag而不是readJournal.CurrentEventsByTag来获取连续的事件流。 Just keep in mind, that it won't complete by itself, but will live on waiting for new events to arrive. 请记住,它本身不会完成,但会继续等待新事件的到来。 You can stop it explicitly ie by using KillSwitch . 您可以显式停止它,即使用KillSwitch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM