nats-io / nats-kafka

NATS to Kafka Bridging
Apache License 2.0
131 stars 32 forks source link

Kafka2Nats doesn't reconnect on failure #85

Open ahuret opened 1 year ago

ahuret commented 1 year ago

Hello !

I'm using nats-kafka bridge from main branch (commit 51f7863d690c07ba3fc0ca674e347ad5dfaaa492) for both Nats2Kafka and Kafka2Nats. For some reason, sometimes, Kafka2Nats connectors fail while fetching new message (see connector.go#L471) and logs said the connector will restart but nothing happened. No error, no reconnect. Then I started to investigate.

As we can see in connector.go#L480 , ConnectorError method is called with conn as first parameter, conn being the BridgeConnector (which is no-op implem of Connector interface). The ConnectorError method actually handle the restart process of the connector (see the method in server.go#L328), at the end this method shutdown and start the connector but since the no-op implementation has been injected as connector, it actually does nothing. I did a quick fix that consists on adding a Connector as parameter in setUpListener method, and injecting this connector instead of the no-op one in ConnectorError, and looks like it works (see here) but the patch doesn't look idiomatic. I wonder what would be a better way to resolve this issue. I would be happy to help !