# Static membership in Kafka Connect

**URL:** <https://forum.confluent.io/t/static-membership-in-kafka-connect/2085>\
**Category:** Kafka Connect\
**Created:** [22 June 2021 10:06 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085 "2021-06-22T10:06:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ommr101](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@ommr101](https://forum.confluent.io/u/ommr101)\
**Post date:** [22 June 2021 10:06 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/1 "2021-06-22T10:06:08Z")

</div>

0

I’m trying to implement the static membership in Kafka Connect. Our Kafka Connect cluster is deployed on K8S using the Strimzi Kafka operator.

I have tried putting the following config for the workers (in the KafkaConnect yaml):

```auto
connector.client.config.override.policy: All
consumer.group.instance.id: somethingsomething

```

And in the HttpSinkConnector class I have this:

```auto
@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
    List<Map<String, String>> configs = new ArrayList<>(maxTasks);
    for (int i = 0; i < maxTasks; i++) {
        Map<String, String> configCopy = new HashMap<>(this.configProps);
        configCopy.put("consumer.override.group.instance.id", Thread.currentThread().getName());

        configs.add(configCopy);
    }
    return configs;
}

```

This gave org.apache.kafka.common.errors.FencedInstanceIdException with some log - …07:07:32,631 ERROR [Consumer instanceId=somethingsomething… because all tasks got somethingsomething as their group.instance.id although it should have get Thread.currentThread().getName().

I have also tried just the following (without the the worker configuration):

```auto
@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
    List<Map<String, String>> configs = new ArrayList<>(maxTasks);
    for (int i = 0; i < maxTasks; i++) {
        Map<String, String> configCopy = new HashMap<>(this.configProps);
        configCopy.put("consumer.group.instance.id", "somethingsomething");

        configs.add(configCopy);
    }
    return configs;
}

```

And that did nothing (no errors, no instanceId in logs) which mean I put this config value in the wrong place.

So how can I achieve static membership on Kafka Connect?

---

<div class="post-metadata">

**Author:** ![rick](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rick/32/49_2.png) [@rick](https://forum.confluent.io/u/rick)\
**Post date:** [22 June 2021 14:02 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/2 "2021-06-22T14:02:41Z")

</div>

@ommr101 can you further define your desired behavior? What specifically do you mean by “static membership”?

---

<div class="post-metadata">

**Author:** ![ommr101](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@ommr101](https://forum.confluent.io/u/ommr101)\
**Post date:** [22 June 2021 14:43 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/3 "2021-06-22T14:43:31Z")

</div>

Hi @rick,  
static membership is a built in feature in Kafka where you can give each consumer in a consumer group a unique id which will be kept during transient failures (such as machine restart or rolling restart) and by that the consumer will not send LeaveGroup Request and a rebalance will not be triggered.  
(more info here - [KIP-345: Introduce static membership protocol to reduce consumer rebalances - Apache Kafka - Apache Software Foundation](https://cwiki.apache.org/confluence/display/KAFKA/KIP-345%3A+Introduce+static+membership+protocol+to+reduce+consumer+rebalances)).

Since Kafka Connect is just an abstraction on top of consumer group (where a connector is a consumer group and a task is a consumer), we theoretically should be able to implement the mentioned static membership simply by giving each task a unique id in its configuration.

That will allow us to skip redundant rebalances each rolling restart (or pod relocation in case of k8s deployment).

Eventually, I’m trying to pass to each task a unique configuration as described in the question but with out success…

---

<div class="post-metadata">

**Author:** ![rick](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rick/32/49_2.png) [@rick](https://forum.confluent.io/u/rick)\
**Post date:** [22 June 2021 15:33 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/4 "2021-06-22T15:33:26Z")

</div>

@ommr101 since the actual consumer configuration is `group.instance.id`, have you tried removing the `consumer` and / or `consumer.override` bits from your config building routines? I’m trying to look at the AK / connector code to see the paths, but thought I’d suggest to see if it’s worth a try.

---

<div class="post-metadata">

**Author:** ![ommr101](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@ommr101](https://forum.confluent.io/u/ommr101)\
**Post date:** [22 June 2021 16:38 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/5 "2021-06-22T16:38:26Z")

</div>

@rick yes I have tried but no success, it looked like the underlaying consumers could not pick up this configuration (`group.instance.id`).

And just so we’ll be on the same page, in that attempt I removed from the worker config the mentioned configs in the question.  
(those configs:

```auto
connector.client.config.override.policy: All
consumer.group.instance.id: somethingsomething

```

)

---

<div class="post-metadata">

**Author:** ![ommr101](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@ommr101](https://forum.confluent.io/u/ommr101)\
**Post date:** [30 June 2021 16:51 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/6 "2021-06-30T16:51:39Z")

</div>

@rick  
HI, any updates?

---

<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:** [30 July 2021 16:52 UTC](https://forum.confluent.io/t/static-membership-in-kafka-connect/2085/7 "2021-07-30T16:52:14Z")

</div>

Closed on 30 July 2021 16:52 UTC

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