Search code examples
apache-kafkaapache-camelazure-eventhub

Connect Camel with EventHubs using Kafka protocol


I am trying to route messages from Camel to Azure EventHubs. EventHubs namespace was created using Kafka enabled flag.

         String eventHubsPassword = "org.apache.kafka.common.security.plain.PlainLoginModule " +
        "required username=\"$ConnectionString\" " + 
        "password=\"<Connection String>\";";

        String eventHubsConfig = 
        "&requestTimeoutMs=30000" +
        "&securityProtocol=SASL_SSL" + 
        "&saslMechanism=PLAIN" +
        "&saslJaasConfig=" + eventHubsPassword;

        from(component + ":queue:" + queue )
        .to("kafka:mock-topic?brokers=" + eventHubsKafkaBrokers + eventHubsConfig)

where mock-topic is the name of event hub, eventHubsKafkaBrokers is like mynamespace.servicebus.windows.net:9093 and <connection string> is the connection string of the event hub namespace.

So I get this log

2019-07-03 23:35:23 INFO  AbstractLogin:53 - Successfully logged in.
2019-07-03 23:35:23 INFO  AppInfoParser:109 - Kafka version : 1.0.0

On sending the message I get

2019-07-03 23:37:51 WARN  NetworkClient:241 - [Producer clientId=producer-2] Connection to node -1 could not be established. Broker may not be available.

What could be wrong? Camel version is 2.21.1. Doesn't camel support SASL_SSL security protocol?


Solution

  • If it helps anybody, I ended up using the amqp support provided by EventHubs. Put the destination of the route to defined amqp component then.

    AMQPComponent authorizedAmqp = AMQPComponent.amqpComponent( eventHubsNamespace, eventHubsUsername, //Shared access policy name eventHubsPassword); //Secret code for this shared access policy main.bind("amqps", authorizedAmqp); ... from('jms://source") .to("amqps" + ":queue:" + eventhubInstance);