简体   繁体   中英

bonsai kafka unable to connect from apache camel

I am trying to connect to bonsai kafka clustur from apche camel springboot app .

Below is my config (password changed)

camel.component.kafka.brokers=https://321312:213213@camel-4054112539.us-east-1.bonsaisearch.net:443
camel.component.kafka.security-protocol=SSL
camel.component.kafka.ssl-truststore-location=C:/Users/meow/tools/jdk1.8.0_291/jre/lib/security/cacerts
camel.component.kafka.ssl-truststore-password=changeit

Below is producer

 public class ActiveSenderRouter extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("timer:kafka-timer?period=5000").bean(MessageCreater.class).to("kafka:mytopic");

    }
}

@Component
class MessageCreater {
    int i = 0;

    public void createMessage(Exchange ex) {
        String message = "my message " + (++i);
        System.out.println("writing to log");
        ex.getIn().setBody(message);
    }
}

I am getting below error , the first line contiues for long and then getting log from second line

2021-06-24 16:27:01.367 WARN 13456 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker camel-4054112539.us-east-1.bonsaisearch.net:443 (id: -1 rack: null) disconnected

2021-06-24 16:35:07.997 WARN 9112 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker camel-4054112539.us-east-1.bonsaisearch.net:443 (id: -1 rack: null) disconnected 2021-06-24 16:35:08.163 ERROR 9112 --- [r://kafka-timer] oacpeDefaultErrorHandler : Failed delivery for (MessageId: 4ACC1A23B54E627-0000000000000000 on ExchangeId: 4ACC1A23B54E627-0000000000000000). Exhausted after delivery attempt: 1 caught: org.apache.kafka.common.errors.TimeoutException: Topic mytopic not present in metadata after 60000 ms.

Message History (complete message history is disabled) --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor
Elapsed (ms) [route1 ] [route1 ] [from[timer://kafka-timer?period=5000]
] [ 60054] ... [route1 ] [to1 ] [kafka:mytopic
] [ 0]

Stacktrace

org.apache.kafka.common.errors.TimeoutException: Topic mytopic not present in metadata after 60000 ms.

2021-06-24 16:35:08.167 WARN 9112 --- [r://kafka-timer] oacamel.component.timer.TimerConsumer : Error processing exchange. Exchange[4ACC1A23B54E627-0000000000000000]. Caused by: [org.apache.kafka.common.errors.TimeoutException - Topic mytopic not present in metadata after 60000 ms.]

org.apache.kafka.common.errors.TimeoutException: Topic mytopic not present in metadata after 60000 ms.

好像你的kafka broker上没有开启自动创建topic,所以需要先创建mytopic然后运行路由,或者开启自动创建topic。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM