morleyc
morleyc

Reputation: 2431

EventStore only showing hexadecimal string in Payload column

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?

Upvotes: 2

Views: 282

Answers (2)

Jakub Konecki
Jakub Konecki

Reputation: 46008

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.

Upvotes: 2

Patrice Tremblay
Patrice Tremblay

Reputation: 11

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();

Upvotes: 1

Related Questions