EvaluationContext Null与Spring集成和Kafka
我试图在SpringIntegration中定义一个简单的消息流,它从一个通道读取消息,然后将消息转储到Kafka队列中。为此,我正在使用。问题是我得到了一个无法破译的EvaluationContext Null与Spring集成和Kafka,spring,spring-boot,spring-integration,apache-kafka,kafka-producer-api,Spring,Spring Boot,Spring Integration,Apache Kafka,Kafka Producer Api,我试图在SpringIntegration中定义一个简单的消息流,它从一个通道读取消息,然后将消息转储到Kafka队列中。为此,我正在使用。问题是我得到了一个无法破译的EvaluationContext错误 以下是我的XML配置: <int:channel id="myStreamChannel"/> <int:gateway id="myGateway" service-interface="com.myApp.MyGateway" > <int:meth
EvaluationContext
错误
以下是我的XML配置:
<int:channel id="myStreamChannel"/>
<int:gateway id="myGateway" service-interface="com.myApp.MyGateway" >
<int:method name="process" request-channel="myStreamChannel"/>
</int:gateway>
<int:channel id="activityOutputChannel"/>
<int:transformer input-channel="myStreamChannel" output-channel="activityOutputChannel" ref="activityTransformer"/>
<int-kafka:outbound-channel-adapter id="kafkaOutboundChannelAdapter"
kafka-producer-context-ref="kafkaProducerContext"
auto-startup="false"
channel="activityOutputChannel"
topic="my-test"
message-key-expression="header.messageKey">
<int:poller fixed-delay="1000" time-unit="MILLISECONDS" receive-timeout="0" task-executor="taskExecutor"/>
</int-kafka:outbound-channel-adapter>
<task:executor id="taskExecutor"
pool-size="5-25"
queue-capacity="20"
keep-alive="120"/>
<int-kafka:producer-context id="kafkaProducerContext" producer-properties="producerProperties">
<int-kafka:producer-configurations>
<int-kafka:producer-configuration broker-list="kafkaserver.com:9092"
key-class-type="java.lang.String"
value-class-type="java.lang.String"
topic="my-test"
key-encoder="stringEncoder"
value-encoder="stringEncoder"
compression-codec="snappy"/>
</int-kafka:producer-configurations>
</int-kafka:producer-context>
当我通过Spring Boot运行应用程序时,会出现以下异常:
创建名为“org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler#0”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:[断言失败]-此参数是必需的;它不能为空
这是堆栈跟踪中有问题的行:
位于org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler.onInit(KafkaProducerMessageHandler.java:68)
下面是第68行发生的情况:
Assert.notNull(this.evaluationContext)代码>
因此,EvaluationContext
为空。我不知道为什么
顺便说一句,当我用一个微不足道的stdout
端点替换Kafka端点来打印消息体时,一切都正常
您能告诉我卡夫卡端点配置有什么问题吗?没有可用的EvaluationContext
。您的问题属于版本不匹配。
Spring引导会拉取不支持IntegrationEvaluationContextAware
的Spring集成核心版本,以填充KafkaProducerMessageHandler
中的EvaluationContext
因此,您应该将Spring Integration Kafka升级到最新版本: