use of org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties in project hono by eclipse.
the class AppConfiguration method messagingKafkaProducerConfig.
/**
* Exposes Kafka producer configuration properties as a Spring bean.
*
* @param commonKafkaClientConfig The common Kafka client configuration.
* @return The properties.
*/
@ConfigurationProperties(prefix = "hono.kafka.producer")
@Profile("kafka")
@Bean
public MessagingKafkaProducerConfigProperties messagingKafkaProducerConfig(final CommonKafkaClientConfigProperties commonKafkaClientConfig) {
final MessagingKafkaProducerConfigProperties configProperties = new MessagingKafkaProducerConfigProperties();
configProperties.setCommonClientConfig(commonKafkaClientConfig);
return configProperties;
}
use of org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties in project hono by eclipse.
the class HonoExampleApplicationBase method createKafkaApplicationClient.
/**
* Creates an application client for Kafka based messaging. Unlike with AMQP, the Kafka clients manage their
* connections to the cluster internally.
* <p>
* NB: if you want to integrate this code with your own software, it might be necessary to copy the trust store to
* your project as well and adopt the file path.
*/
private ApplicationClient<? extends MessageContext> createKafkaApplicationClient() {
final Map<String, String> properties = new HashMap<>();
properties.put("bootstrap.servers", HonoExampleConstants.HONO_MESSAGING_HOST + ":" + port);
// add the following lines with appropriate values to enable TLS
// properties.put("ssl.truststore.location", "/path/to/file");
// properties.put("ssl.truststore.password", "secret");
final CommonKafkaClientConfigProperties commonClientConfig = new CommonKafkaClientConfigProperties();
commonClientConfig.setCommonClientConfig(properties);
final MessagingKafkaConsumerConfigProperties consumerConfig = new MessagingKafkaConsumerConfigProperties();
consumerConfig.setCommonClientConfig(commonClientConfig);
consumerConfig.setConsumerConfig(Map.of("group.id", KAFKA_CONSUMER_GROUP_ID));
final MessagingKafkaProducerConfigProperties producerConfig = new MessagingKafkaProducerConfigProperties();
producerConfig.setCommonClientConfig(commonClientConfig);
final KafkaProducerFactory<String, Buffer> producerFactory = CachingKafkaProducerFactory.sharedFactory(vertx);
return new KafkaApplicationClientImpl(vertx, consumerConfig, producerFactory, producerConfig);
}
use of org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties in project hono by eclipse.
the class IntegrationTestSupport method getKafkaProducerConfig.
/**
* Creates properties for connecting a producer to Kafka.
*
* @return The properties.
*/
public static MessagingKafkaProducerConfigProperties getKafkaProducerConfig() {
LOGGER.info("Configured to connect to Kafka on {}", IntegrationTestSupport.DOWNSTREAM_BOOTSTRAP_SERVERS);
final MessagingKafkaProducerConfigProperties consumerConfig = new MessagingKafkaProducerConfigProperties();
consumerConfig.setProducerConfig(Map.of(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, IntegrationTestSupport.DOWNSTREAM_BOOTSTRAP_SERVERS));
return consumerConfig;
}
use of org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties in project hono by eclipse.
the class KafkaApplicationClientImplTest method setUp.
/**
* Sets up fixture.
*
* @param vertx The vert.x instance to use.
*/
@BeforeEach
void setUp(final Vertx vertx) {
final MockProducer<String, Buffer> mockProducer = KafkaClientUnitTestHelper.newMockProducer(true);
final CachingKafkaProducerFactory<String, Buffer> producerFactory = CachingKafkaProducerFactory.testFactory(vertx, (n, c) -> KafkaClientUnitTestHelper.newKafkaProducer(mockProducer));
tenantId = UUID.randomUUID().toString();
mockConsumer = new KafkaMockConsumer(OffsetResetStrategy.EARLIEST);
final CommonKafkaClientConfigProperties commonConfig = new CommonKafkaClientConfigProperties();
commonConfig.setCommonClientConfig(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "kafka"));
final MessagingKafkaConsumerConfigProperties consumerConfig = new MessagingKafkaConsumerConfigProperties();
consumerConfig.setCommonClientConfig(commonConfig);
consumerConfig.setConsumerConfig(Map.of("client.id", "application-test-consumer"));
final MessagingKafkaProducerConfigProperties producerConfig = new MessagingKafkaProducerConfigProperties();
producerConfig.setCommonClientConfig(commonConfig);
producerConfig.setProducerConfig(Map.of("client.id", "application-test-sender"));
client = new KafkaApplicationClientImpl(vertx, consumerConfig, producerFactory, producerConfig);
client.setKafkaConsumerFactory(() -> mockConsumer);
}
use of org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties in project hono by eclipse.
the class ApplicationConfig method kafkaEventConfig.
/**
* Exposes configuration properties for the Kafka producer that publishes events as a Spring bean.
*
* @return The properties.
*/
@ConfigurationProperties(prefix = "hono.kafka.event")
@Bean
public MessagingKafkaProducerConfigProperties kafkaEventConfig() {
final MessagingKafkaProducerConfigProperties configProperties = new MessagingKafkaProducerConfigProperties();
configProperties.setCommonClientConfig(commonKafkaClientConfig());
return configProperties;
}
Aggregations