java - 拦截 Spring Cloud Stream 目标绑定以动态修改生产者属性
问题描述
我试图找到一种方法来拦截 Spring Cloud Stream 3.1.1 目标绑定,以便在我的应用程序中动态修改一些属性。我来到了下面的代码片段,但它似乎只适用于动态绑定,而在我的情况下,通道是专门定义的,并且没有使用动态目标,所以我不确定我在这里缺少什么。
@Bean
public NewDestinationBindingCallback<KafkaProducerProperties> bindingConfigurer() {
return ((channelName, channel, producerProperties, extendedProducerProperties) -> {
if ("foo".equals(channelName)) {
producerProperties.setUseNativeEncoding(producerUseNativeEncoding);
producerProperties.setPartitionCount(producerPartitionCount);
}
});
}
解决方案
推荐阅读
- mysql - SQL 连接表并在右表中显示不匹配记录的默认值
- c# - 如何删除同一字符串中两个单词之间的空格
- pandas - 使用正则表达式匹配数据框中的列
- ios - 如何仅通过邀请将 iOS 应用分发给 50k 用户?
- here-api - Here Maps javascript api 3.1 and Internet Explorer support
- python - 如何修复“未定义”,但已定义?
- c# - OnCollisonEnter(Collision other) 没有检测到我的对象?
- testing - 如何捕获失败场景的屏幕截图并将其附加到 testcafe 中的报告?
- java - 为什么我们需要向上转换或向下转换 Java 中的任何对象?用例子告诉我实时使用
- google-analytics - GA 未记录“添加到购物车的会话”