Description
- I have a pubSubSource connector in Kafka Connect Distributed mode that is simply reading from a PubSub subscription and writing into a Kafka topic. The issue is, even if I am publishing one message to GCP PubSub, I am getting this message written twice in my Kafka topic.
How to reproduce
Deploy Kafka and Kafka connect
Create a connector with below
pubSubSource
configurations:curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d '{ "name": "pubSubSource", "config": { "connector.class":"com.google.pubsub.kafka.source.CloudPubSubSourceConnector", "key.converter": "org.apache.kafka.connect.json.JsonConverter", "value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter", "tasks.max":"1", "cps.subscription":"pubsub-test-sub", "kafka.topic":"kafka-sub-topic", "cps.project":"test-project123", "gcp.credentials.file.path":"/tmp/gcp-creds/account-key.json" } }'
Below are the Kafka-connect configurations:
"plugin.path": "/usr/share/java,/usr/share/confluent-hub-components" "key.converter": "org.apache.kafka.connect.json.JsonConverter" "value.converter": "org.apache.kafka.connect.json.JsonConverter" "key.converter.schemas.enable": "false" "value.converter.schemas.enable": "false" "internal.key.converter": "org.apache.kafka.connect.json.JsonConverter" "internal.value.converter": "org.apache.kafka.connect.json.JsonConverter" "config.storage.replication.factor": "1" "offset.storage.replication.factor": "1" "status.storage.replication.factor": "1"
Publish a message to the PubSub topic using the below command:
gcloud pubsub topics publish test-topic --message='{"someKey":"someValue"}'
Read messages from the destination Kafka topics:
/usr/bin/kafka-console-consumer --bootstrap-server xx.xxx.xxx.xx:9092 --topic kafka-topic --from-beginning # Output {"someKey":"someValue"} {"someKey":"someValue"}
Why is this happening, is there something that I am doing wrong?