Search in sources :

Example 1 with KafkaProducerMessageHandler

use of org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler in project spring-integration-samples by spring-projects.

the class Application method handler.

@ServiceActivator(inputChannel = "toKafka")
@Bean
public MessageHandler handler(KafkaTemplate<String, String> kafkaTemplate) {
    KafkaProducerMessageHandler<String, String> handler = new KafkaProducerMessageHandler<>(kafkaTemplate);
    handler.setMessageKeyExpression(new LiteralExpression(this.properties.getMessageKey()));
    return handler;
}
Also used : LiteralExpression(org.springframework.expression.common.LiteralExpression) KafkaProducerMessageHandler(org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)1 LiteralExpression (org.springframework.expression.common.LiteralExpression)1 ServiceActivator (org.springframework.integration.annotation.ServiceActivator)1 KafkaProducerMessageHandler (org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler)1