EventStore only showing hexadecimal string in Payload column
Asked Answered
R

2

2

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?

Rooted answered 30/3, 2013 at 21:26 Comment(0)
F
2

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.

Fermi answered 9/5, 2013 at 8:51 Comment(0)
C
1

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();
Cassidycassie answered 11/4, 2013 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.