MONGODB KAFKA Source CONNECTOR How to change Kafka Parition key

236 Views Asked by At

1; I try to use valuetokey to change partition key with error "Only Struct objects supported for [copying fields from value to key], found: java.lang.String" ; 2; I want update The source code MongoSourceTask.poll() for return struct type, but couldn't change it;

how to solve it,thanks

enter image description here

2

There are 2 best solutions below

0
On

I faced a similar issue which got resolved by defining:

"output.schema.value":"your schema here"

in the connector configuration

0
On

You shouldn't modify the connector source code.

You can use JSON (with schemas enabled), Avro, or Protobuf to get a Struct type with accessible fields

From your error, sounds like you'd used the StringConverter or JSONConverter with schemas disabled