Repository: tchiotludo/akhq

Issue #657: Support for Azure event hub
Created: 2021-04-07T09:28:48Z
Hello!
I tried to use AKHQ to connect to a Event Hub (Azure) and it does not work with AKHQ. Example of configuration:
connections:
  my-cluster:
    properties:
      bootstrap.servers: "DOMAIN.servicebus.windows.net:9093"
      security.protocol: SASL_SSL
      sasl.mechanism: PLAIN
      sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="Endpoint=sb://DOMAIN.servicebus.windows.net/;SharedAccessKeyName=KEYNAME;KEYNAME=VEYVALUE";

(Example from: https://docs.microsoft.com/fr-fr/azure/event-hubs/event-hubs-quickstart-kafka-enabled-event-hubs)
On the AKHQ launched, I get this error in console:
2021-04-07 10:48:20,823 WARN  r-thread-2 .a.k.c.a.AdminClientConfig The configuration 'sasl.jaas.config' was supplied but isn't a known config.
2021-04-07 10:48:22,397 WARN  r-thread-2 org.akhq.log.access        [Date: 2021-04-07T10:48:20.484018+02:00] [Duration: 1913 ms] [Url: GET /api/my-cluster/topic] [Status: 500] [Ip: /127.0.0.1] [User: -]
2021-04-07 10:48:22,414 ERROR Group-1-11 o.a.c.ErrorController      Error for List Log dir
(...)
Caused by: org.apache.kafka.common.errors.UnsupportedVersionException: The broker does not support DESCRIBE_LOG_DIRS

With the same configuration in another tool like Conduktor, it works.

Duplicate issue #1364: Failing to identify leader when connecting to Azure EventHubs
Created: 2023-02-03T23:59:54Z
Azure EventHubs has a "kafka projection" mode. It looks a lot like kafka but has some subtle differences I think.
When attempting to connect to eventhubs akhq has an error:

2023-02-03 22:53:57,298 [1 31mERROR[0 39m [35mr-thread-5[0 39m [36mi.m.h.server.RouteExecutor[0 39m Unexpected error occurred: Error encoding object [org.akhq.utils.ResultPagedList@691ab908] to JSON: Leader not found (through reference chain: org.akhq.utils.ResultPagedList["results"]->org.akhq.utils.PagedList[0]->org.akhq.models.Topic["partitions"]->java.util.ArrayList[0]->org.akhq.models.Partition["leader"])

Here is my configuration:
application.yaml
akhq:
  connections:
    kafka:
      properties:
        bootstrap.servers: "recovery-{{ .Values.global.envName }}.servicebus.windows.net:9093"
        security.protocol: SASL_SSL
        sasl.mechanism: PLAIN
        sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="{{ .Values.global.AZURE_EVENT_HUBS_ENDPOINT }}";
https://github.com/tchiotludo/akhq/blob/dev/src/main/java/org/akhq/models/Partition.java#L40-L46
I believe this is the problem code, I belive that EventHubs is reporting that there are no replicas therefore the code to identify the leader is failing.
    public Node.Partition getLeader() {
        return nodes
            .stream()
            .filter(Node.Partition::isLeader)
            .findFirst()
            .orElseThrow(() -> new NoSuchElementException("Leader not found"));
    }
Since there are no replicas, the .findFirst() finds nothing. I'm assuming the fix will be to either add the partition itself to the nodes list in the case where there are no replicas, or to return this.id in the getLeader() function instead of throwing an exception.

Closing comment (2023-02-13T20:52:26Z): Event hub support can be cool, but I think it will break on other edge case, PR are welcome, closing due to duplicate of #657