EventStore only showing hexadecimal string in Payload column

房东的猫 提交于 2019-12-08 01:55:16

问题


As far as I can tell I should have JSON showing in Payload column in my SQL database Commits table, however I have a long hexadecimal string.

My wireup code is as per the sample with the following edits:

private static IStoreEvents WireupEventStore()
{
        return Wireup.Init()
        .LogToOutputWindow()
        .UsingInMemoryPersistence()
        .UsingSqlPersistence("EventStore") // Connection string is in app.config
            .WithDialect(new MsSqlDialect())
            .EnlistInAmbientTransaction() // two-phase commit
            .InitializeStorageEngine()
            .UsingJsonSerialization()
        .HookIntoPipelineUsing(new[] { new AuthorizationPipelineHook() })
        .UsingSynchronousDispatchScheduler()
            .DispatchTo(new DelegateMessageDispatcher(DispatchCommit))
        .Build();
}

Any idea how to get JSON and make debugging easier?


回答1:


Just create the following view:

CREATE VIEW [dbo].[DeserializedCommits]
    AS 
    SELECT 
         [StreamId]
        ,[StreamRevision]
        ,[Items]
        ,[CommitId]
        ,[CommitSequence]
        ,[CommitStamp]
        ,[Dispatched]
        ,CAST([Headers] AS VARCHAR(MAX)) AS [Headers]
        ,CAST([Payload] AS VARCHAR(MAX)) AS [Payload]
    FROM [dbo].[Commits]

You can than query your event store for specific events using LIKE on Payload column.




回答2:


A query similar to this one will get you the string content of the Payload column:

Commits
.Select(c => System.Text.Encoding.UTF8.GetString(c.Payload.ToArray()))
.ToList();


来源:https://stackoverflow.com/questions/15723678/eventstore-only-showing-hexadecimal-string-in-payload-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!