# How to enable compression in Kafka Source Connector (JDBC Source Connector)

**URL:** <https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114>\
**Category:** Kafka Connect\
**Created:** [4 March 2021 16:05 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114 "2021-03-04T16:05:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poornaraj](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Poornaraj](https://forum.confluent.io/u/Poornaraj)\
**Post date:** [4 March 2021 16:05 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/1 "2021-03-04T16:05:25Z")

</div>

I tried using this code to enable compression in the source connector. It is not working. Also my cluster is enabled with `auto.create.topics.enable = true`.

```auto
curl -H 'Content-Type:application/json' -X POST localhost:8083/connectors -d ' {
"name": "Kafka_Compression_Connector",
"config": {
        "connector.class" : "io.confluent.connect.jdbc.JdbcSourceConnector",
		"connection.password" : "pwd",
		"topic.prefix" : "kafka_Compression_test"
		"mode" : "bulk"
		"table.whitelist" : "testtable"
		"poll.interval.ms" : "3000"
		"topic.creation.default.partitions" : 4,
        "topic.creation.default.replication.factor": 1,
        "topic.creation.default.compression.type" : "snappy"
        }'

```

When I tested with 10000 records from the table. Size of the topic with compression and without compression is same. On describing the topic in cluster. Compression Type is not showing.

---

<div class="post-metadata">

**Author:** ![gianlucanatali](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/gianlucanatali/32/302_2.png) [@gianlucanatali](https://forum.confluent.io/u/gianlucanatali)\
**Post date:** [5 March 2021 09:27 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/2 "2021-03-05T09:27:33Z")

</div>

Hi @Poornaraj , is the topic already created? That config will be used only on topic creation

---

<div class="post-metadata">

**Author:** ![Poornaraj](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Poornaraj](https://forum.confluent.io/u/Poornaraj)\
**Post date:** [6 March 2021 04:39 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/3 "2021-03-06T04:39:21Z")

</div>

Hi, No the topic is not created. It will be created once the Source Connector is running, as we have turned on the auto.create.topics.enable=true.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [8 March 2021 09:24 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/4 "2021-03-08T09:24:31Z")

</div>

Just because `auto.create.topics.enable=true` doesn’t mean that the topic might not already exist, e.g. from a previous test.

Can you try the test again, and show the output here of topic list beforehand, Kafka Connect config used, and then config properties list afterwards of the created topic?

---

<div class="post-metadata">

**Author:** ![Poornaraj](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Poornaraj](https://forum.confluent.io/u/Poornaraj)\
**Post date:** [8 March 2021 10:09 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/5 "2021-03-08T10:09:52Z")

</div>

Hi Sir, I could see the topic has been created automatically using the topic\_prefix\_name with the table name after that. But for 10K records it has occupied 10MB without any compression enabled in the source connector. After i added below lines to the source code to enable compression, still for the same 10K records it has occupied 10MB.

“topic.creation.default.compression.type” : “snappy”

kindly advise how to make this work inside source connector.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [8 March 2021 10:14 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/6 "2021-03-08T10:14:15Z")

</div>

It’s more important to first ascertain if the compression setting has actually been applied, than compare the size of records on disk.

Can you show the output of `kafka-topics --bootstrap-server your_broker:9092 --topic your_topic --describe` please?

And also run the test again and find in the Kafka Connect worker log the line `INFO Created topic` and paste that line here too.

I’m basing this on [the blog that I wrote](https://rmoff.net/2021/01/06/creating-topics-with-kafka-connect/) and the details that Kafka shows at the time of creating a new topic.

---

<div class="post-metadata">

**Author:** ![Poornaraj](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Poornaraj](https://forum.confluent.io/u/Poornaraj)\
**Post date:** [10 March 2021 06:12 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/7 "2021-03-10T06:12:31Z")

</div>

Yes i have checked this. Compression is not applied while describing the Topic even when i used the above “topic.creation.default.compression.type” : “snappy” in the source connector.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [10 March 2021 09:03 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/8 "2021-03-10T09:03:28Z")

</div>

Did you try this? Can you post the results?

> [@rmoff](#):
>
> And also run the test again and find in the Kafka Connect worker log the line `INFO Created topic` and paste that line here too.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [24 March 2021 09:03 UTC](https://forum.confluent.io/t/how-to-enable-compression-in-kafka-source-connector-jdbc-source-connector/1114/9 "2021-03-24T09:03:35Z")

</div>

Closed on 24 March 2021 09:03 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
