[英]Use @Gateway with Spring-Integration-Kafka
Using Spring-Integration-Kafka can we still use @MessagingGateway and @Gateway. 使用Spring-Integration-Kafka,我们仍然可以使用@MessagingGateway和@Gateway。
My current code looks like this: 我当前的代码如下所示:
@MessagingGateway
public interface OrderGateway {
@Gateway(requestChannel = "requestChannel", replyChannel = "replyChannel",headers = {@GatewayHeader(name = "kafka_topic", value ="requestTopic"))
Order order(Item item)
}
on my Spring Spring configuration: 在我的Spring Spring配置上:
@Bean
@ServiceActivator(inputChannel = "requestChannel")
public MessageHandler kafkaMessageHandler(KafkaTemplate kafkaTemplate) {
KafkaProducerMessageHandler<String, String> messageHandler = new KafkaProducerMessageHandler<>(kafkaTemplate);
messageHandler.setMessageKeyExpression(new LiteralExpression("spring-integration-kafka"));
messageHandler.setTopicExpression(new SpelExpressionParser().parseExpression("headers.kafka_topic"));
return messageHandler;
}
with this setup I get and error saying: 通过这种设置,我得到错误提示:
by: org.springframework.messaging.core.DestinationResolutionException: no output-channel or replyChannel header available
You don't appear to have shown the complete configuration. 您似乎没有显示完整的配置。
The gateway is expecting a reply but the kafkaMessageHandler
produces no reply (unless the template is a ReplyingKafkaTemplate
) and will lose the replyChannel
header. 网关期望答复,但是
kafkaMessageHandler
产生答复(除非模板是ReplyingKafkaTemplate
),并且将丢失replyChannel
标头。
So, presumably, you are trying to send a reply from someplace else. 因此,大概是您正在尝试从其他地方发送答复。
If you are expecting request/reply semantics; 如果您期望请求/回复语义; use the new outbound gateway .
使用新的出站网关 。
Where the template has to be a ReplyingKafkaTemplate
. 模板必须是
ReplyingKafkaTemplate
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.