spring-boot - Spring Cloud Stream - 发送时出现 StreamBridge 错误
问题描述
我正在使用 Spring Cloud Stream 3.1.3 和带有模式注册表的 binder kafka 开发一个应用程序。这是我为 Producer 写的课程
@Slf4j
@EnableAutoConfiguration
@Component
public class Producer {
private static final String PARTITION_KEY = "partitionKey";
private static final String MESSAGE_ID = "messageId";
@Autowired
private StreamBridge streamBridge;
public void produce(int messageId, Object message) {
log.info("Sending test message through Kafka: {}", message);
Message<Object> toProduce = MessageBuilder
.withPayload(message)
.setHeader(PARTITION_KEY, messageId)
.build();
streamBridge.send("produceMessage-out-0", toProduce);
}
}
streamBridge.send
调用时出现此错误:
java.lang.ClassCastException: class org.springframework.cloud.stream.function.StreamBridge$$Lambda$1557/0x0000000800ab4c40 cannot be cast to class org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInv
ocationWrapper (org.springframework.cloud.stream.function.StreamBridge$$Lambda$1557/0x0000000800ab4c40 and org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper are in unnamed module of
loader 'app')
帮助表示赞赏。谢谢
编辑:我发现这个问题描述了我的问题。
https://github.com/spring-cloud/spring-cloud-stream/issues/2101
是否有解决方法可以使我的代码与 3.1.3 版本一起使用?
解决方案
推荐阅读
- wso2 - 在 WSO2 APIM 3.1.0 中执行在 MySQL 数据库上创建表的数据库脚本失败
- azure - 我们需要更改 Azure 中的 UPN。我们需要在 Snowflake 中/使用 Snowflake 做什么才能继续登录吗?
- sql - 选择列在哪里连续包含三个大写字母
- java - java - 如何在java中需要表达式的地方分配变量?
- c# - 来自部分视图的表单上的多个提交按钮,只有列表中的第一个提交数据
- c# - localhost 证书的潜在风险错误
- python - Postgresql 脚本将点插入到接受 NULL 值的表中
- powershell - 延迟启动到 powershell 脚本
- c# - EF6 Dynamic Linq 将字符串转换为十进制
- mule - 将 Mule 运行时从 3.8.4 升级到 3.9.2 以下与依赖项相关的问题 tanukisoft:wrapper:jar:3.5.35