I am using Spring integration 5.0.6. I have gone though it's document and created following code which listens on a HTTP endpoint and publish to a kafka topic.
Everything is working fine and I am receiving message at topic also. But at HTTP client there is no reply sent, it's giving "No reply received within timeout".
How can I send a reply back to http caller in below code:
@Bean
public DirectChannel replyChannel() {
return new DirectChannel();
}
@Bean(name = "restInputFlow")
public IntegrationFlow send() {
return IntegrationFlows
.from(Http.inboundGateway("/push").requestMapping(m -> m.methods(HttpMethod.POST))
.requestPayloadType(String.class).replyChannel(replyChannel()))
.transform(new Transformer())
.handle(kafkaMessageHandler(producerFactory(), getKafkaSourceTopic()))
.enrichHeaders(
c -> c.header(org.springframework.integration.http.HttpHeaders.STATUS_CODE, HttpStatus.CREATED))
.get();
}
private KafkaProducerMessageHandlerSpec<GenericRecord, GenericRecord, ?> kafkaMessageHandler(
ProducerFactory<GenericRecord, GenericRecord> producerFactory, String topic) {
return Kafka.outboundChannelAdapter(producerFactory)
.messageKey("key").headerMapper(mapper())
.topicExpression("headers[kafka_topic] ?: '" + topic + "'")
.configureKafkaTemplate(t -> t.id("kafkaTemplate:" + topic));
}
Thanks for any help.