Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In ES, event data is not being stored as JSON objects but just as strings #81

Closed
drozzy opened this issue Sep 22, 2017 · 1 comment
Closed

Comments

@drozzy
Copy link

drozzy commented Sep 22, 2017

It seems like the event data is being sent as a string and not as json to event-store.
For JSON you need to set data_content_type of extreme lib to "1" (it is set to 0 by default):
https://github.com/exponentially/extreme/blob/5bc3b34a94bb8530964b674261b978910339c77c/lib/extreme.ex#L137

I'm not sure where you set this.
Here is my events in Gregg's event store sent by commanded (pay attention to the "data" element):

{
    "correlationId": "ccf88746-06ba-459f-b93a-9ccce1cebdf1",
    "readerPosition": {
        "$s": {
            "$ce-account": 6
        }
    },
    "events": [
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventType": "Elixir.Bank.Events.AccountOpened",
            "data": "{\"timestamp_utc\":1506096118,\"initial_balance\":0,\"client_id\":\"3324-john.oliver\",\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"7e083e9e-bcf6-4cc5-8cc8-47d84f14ec50\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 0
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 1,
            "eventType": "Elixir.Bank.Events.MoneyDeposited",
            "data": "{\"timestamp_utc\":1506096512,\"amount\":1000,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"fc725dea-c9d9-4cb2-aa47-dcc0cc8ca59c\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 1
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 2,
            "eventType": "Elixir.Bank.Events.MoneyWithdrawn",
            "data": "{\"timestamp_utc\":1506096582,\"amount\":25,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"87c5ffdf-d424-48df-878f-ce276265487a\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 2
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 3,
            "eventType": "Elixir.Bank.Events.MoneyDeposited",
            "data": "{\"timestamp_utc\":1506096699,\"amount\":33,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"da047c54-7349-400b-a065-a9313413716c\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 3
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 4,
            "eventType": "Elixir.Bank.Events.MoneyWithdrawn",
            "data": "{\"timestamp_utc\":1506096699,\"amount\":661,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"61df179b-03ef-40f5-90e7-e9852a0aa526\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 4
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 5,
            "eventType": "Elixir.Bank.Events.MoneyDeposited",
            "data": "{\"timestamp_utc\":1506096699,\"amount\":500,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"2292148d-70ea-4885-b4cb-968070c2f2d2\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 5
                }
            }
        },
        {
            "eventStreamId": "account-333-121-568-3245",
            "eventNumber": 6,
            "eventType": "Elixir.Bank.Events.MoneyDeposited",
            "data": "{\"timestamp_utc\":1506096699,\"amount\":22,\"account_id\":\"333-121-568-3245\"}",
            "metadata": "{\"$correlationId\":\"fd6ac525-a7e6-450d-9781-f280245800f6\"}",
            "readerPosition": {
                "$s": {
                    "$ce-account": 6
                }
            }
        }
    ]
}

Any tips on how to hack it to work?

@slashdotdash
Copy link
Member

slashdotdash commented Sep 22, 2017

Closing this issue and have opened one in the Commanded Extreme adapter project (#4).

Here's the source where the Commanded.EventStore.Adapters.Extreme sets data_content_type: 0 to append new events. You could try changing it, and the metadata_content_type, to see if that has any affect.

Pull request gladly accepted if that works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants