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

Send valid JSON from Source #35

Open
vringar opened this issue Jan 26, 2020 · 4 comments
Open

Send valid JSON from Source #35

vringar opened this issue Jan 26, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@vringar
Copy link

vringar commented Jan 26, 2020

When sending messages from a Zeebe workflow with the example ping-pong configs, messages are overly escaped to the point that they aren't valid JSON anymore:

{\"key\":2251799813685264,
\"type\":\"ping\",
\"customHeaders\":{\"topic\":\"pong\"},
\"workflowInstanceKey\":2251799813685256,
\"bpmnProcessId\":\"ping-pong\",
\"workflowDefinitionVersion\":1,
\"workflowKey\":2251799813685249,
\"elementId\":\"ServiceTask_1sx6rbe\",
\"elementInstanceKey\":2251799813685263,
\"worker\":\"kafka-connector\",
\"retries\":3,\"deadline\":1580056465256,
\"variables\":\"{\\\"foo\\\":\\\"bar\\\",\\\"key\\\":123456,\\\"name\\\":\\\"pong\\\"}\",
\"variablesAsMap\":{\"foo\":\"bar\",\"key\":123456,\"name\":\"pong\"}}

and while this works for the round trip other consumers expecting proper JSON are failing on this message.

@menski menski self-assigned this Jan 27, 2020
@menski
Copy link
Contributor

menski commented Jan 29, 2020

@npepinpe after checking the code I think this is expected at the moment? The source task publishes a message with the record json as string schema, which leads to the observed escaping. Can you confirm this?

@menski menski assigned npepinpe and unassigned menski Jan 29, 2020
@npepinpe
Copy link
Contributor

That's correct, the current solution is just to publish the record as a string - the other side has to parse it back as JSON. I'll try out with the JSON schema and report back.

@npepinpe npepinpe added the enhancement New feature or request label Jan 29, 2020
@vringar
Copy link
Author

vringar commented Feb 3, 2020

From our exploration we found two options:

  1. Remove the JSON mapper in source.json so the already valid JSON generated in the SourceTask doesn't get scrambled
  2. Define a new Schema with the schema type Schema.Type.STRUCT and define the right mappings there and then just pass the ActivatedJob

We chose the first one because it was easier for us.
@npepinpe what JSON schema are you referring to? Is there a Kafka data schema for JSON already?

@berndruecker
Copy link
Collaborator

@vringar: So you switched from JsonConverter to a StringConverter (here: #18)? That could maybe make sense to change that in the example too - right? Would you be willing to provide a Pull Request for it?

For the Schema: I think we should switch to the typical Kafka transformation logic (#18) - that makes it more flexible. But currently we still wait for feedback on the usage before investing in that.

Can you share anything about your use case? Also happy to get that via email offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants