I'm trying to connect to a Message Hub Service. I can connect if I use the REST API but when I try to connect from my Java program there's always a timeout
I'm using the next configuration:
Properties producerProps = new Properties();
producerProps.put(SslConfigs.SSL_PROTOCOL_CONFIG, "TLSv1.2");
producerProps.put(SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG, "TLSv1.2");
producerProps.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/security/cacerts");
producerProps.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "changeit");
producerProps.put(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "JKS");
producerProps.put(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, "HTTPS");
producerProps.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.ByteArraySerializer.class);
producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.ByteArraySerializer.class);
producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka01-prod01.messagehub.services.us-south.bluemix.net:9093,kafka02-prod01.messagehub.services.us-south.bluemix.net:9093,kafka03-prod01.messagehub.services.us-south.bluemix.net:9093,kafka04-prod01.messagehub.services.us-south.bluemix.net:9093,kafka05-prod01.messagehub.services.us-south.bluemix.net:9093");
producerProps.put(ProducerConfig.CLIENT_ID_CONFIG, "myApiKey");
KafkaProducer<byte[], byte[]> kafkaProducer = new KafkaProducer<>(producerProps);
ProducerRecord<byte[], byte[]> producerRecord = new ProducerRecord<>("myTopic", "records".getBytes(), "[{ \"value\" : \"test\" }]".getBytes());
RecordMetadata metadata = kafkaProducer.send(producerRecord).get();
System.out.println("Offset: " + metadata.offset());
kafkaProducer.close();
After a while the error is
Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 231 ms.
at org.apache.kafka.clients.producer.KafkaProducer$FutureFailure.<init>(KafkaProducer.java:706)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:453)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:339)
I'm using kafka-clients version 0.9.0.0
Any thoughts?