最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

postgresql - How to get replication events for all databases - Stack Overflow

programmeradmin8浏览0评论

Replication events are displayed by ASP.NET Core 9 MVC controller according using code:

public async Task Index()
{
    const string slotName = "all_slot";
    await ctx.Database.ExecuteSqlAsync("create publication Jalgi_pub for all tables;");
    await ctx.Database.ExecuteSqlAsync(@$"SELECT * FROM pg_create_logical_replication_slot({slotName}, 'pgoutput' , false );");

    await using LogicalReplicationConnection conn = new("host=localhost;database=postgres");
    await conn.Open();

    PgOutputReplicationSlot slot = new(slotName);
    CancellationTokenSource cancellationTokenSource = new();

    await foreach (PgOutputReplicationMessage m in conn.StartReplication(
        slot, new PgOutputReplicationOptions("jalgi_pub", PgOutputProtocolVersion.V4), cancellationTokenSource.Token))
    {
        await Response.WriteAsync($"{m.GetType().Name}<br>");
        conn.SetReplicationStatus(m.WalEnd);
    }
}

Code is based is sample from .html

This shows events from Postgres database only. How to show events from all databases in the cluster?

发布评论

评论列表(0)

  1. 暂无评论