DarioBalinzo / kafka-connect-elasticsearch-source

Kafka Connect Elasticsearch Source
Apache License 2.0
65 stars 38 forks source link

Now that ElasticSourceConnector is working, how to consume messages using Java from Kafka Topic? #85

Closed srinivasagank closed 1 year ago

srinivasagank commented 2 years ago

I configured ElasticSourceConnector successfully, and it is working. Now I want to consume messages that comes to Kafka Topic using Java code. Do I have to use JSON serializer/deserializer, or how do I receive Java object? I am using my_awesome_index as index prefix. Kindly share the Java code example. Thanks Srinivasagan

srinivasagank commented 2 years ago

In my Spring Boot Application...

srinivasagank commented 2 years ago

POST /my_awesome_index/_doc { "greeting":"Hello", "receiver":"World", "@timestamp": "2022-02-02T16:38:53.0870292"

}

srinivasagank commented 2 years ago

name=es-source connector.class=com.github.dariobalinzo.ElasticSourceConnector tasks.max=1 es.host=localhost es.port=9200 index.prefix=my_awesomeindex topic.prefix=es incrementing.field.name=@timestamp

DarioBalinzo commented 1 year ago

I configured ElasticSourceConnector successfully, and it is working. Now I want to consume messages that comes to Kafka Topic using Java code. Do I have to use JSON serializer/deserializer, or how do I receive Java object? I am using my_awesome_index as index prefix. Kindly share the Java code example. Thanks Srinivasagan

It depends if you have used json serialization or avro serialization in the connector. You can also use the kafka console consumer or kafka avro console consumer to check the format of the topics in you kafka cluster.

srinivasagank commented 1 year ago

Thanks, you can close the issue. I am planning to use HttpSinkConnector.