【Azure 事件中心】Spring Boot 集成 Event Hub(azure-spring-cloud-stream-binder-eventhubs)指定Partition Key有异常消息
2022-04-11 20:09
1251 查看
问题描述
在Spring Boot应用中集成Event Hub,发送消息时指定Partition Key,日志中发现异常:
应用使用Event Hub版本为
<dependency> <groupId>com.azure.spring</groupId> <artifactId>azure-spring-cloud-stream-binder-eventhubs</artifactId> <version>2.5.0</version> </dependency>
发送消息指定Partition Key
@RestController public class ReactiveEventProducerController { private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveEventProducerController.class); @Autowired private Sinks.Many<Message<String>> many; @PostMapping("/messages/reactive") public ResponseEntity<String> reactiveSendMessage(@RequestParam String message) { LOGGER.info("Reactive method to send message: {} to destination.", message); many.emitNext(MessageBuilder.withPayload(message).setHeaderIfAbsent(EventHubHeaders.PARTITION_KEY, String.valueOf(vin.hashCode())).build(), Sinks.EmitFailureHandler.FAIL_FAST); return ResponseEntity.ok(message); } @GetMapping("/") public String welcome() { return "welcome"; } }
异常消息
{"@timestamp":"2022-04-05 13:15:08.643","level":"WARN","host":"bogon","APP":"myehapp","microservice":"ehcenter",
"class":"com.azure.spring.integration.eventhub.converter.EventHubMessageConverter","trackingID":"","spanID":"",
"data":"System property azure_partition_key(1916947495) is not allowed to be defined and will be ignored.","xcptn":""}
问题解答
经过多次测试验证,这个异常消息只是一个Warning(警告),并不影响真正消息的发送。 可以使用Service Bus Explorer( https://github.com/paolosalvatori/ServiceBusExplorer )工具进行查看发送端发送的消息。此外,在消费数据的时候,加上EventHubHeaders.RAW_PARTITION_ID 就可以查看分区情况。
message.getHeaders().get(EventHubHeaders.RAW_PARTITION_ID))
相关文章推荐
- 非spring boot (即spring) 使用/集成 Spring cloud Config 分布式配置中心
- springboot+cloud 学习(三)消息中间件 RibbitMQ+Stream
- Spring Cloud(十一)高可用的分布式配置中心 Spring Cloud Bus 消息总线集成(RabbitMQ)
- 将消息中心改造成springboot项目,并集成maven打包docker image
- Spring Cloud Stream - 构建消息事件驱动的微服务
- Spring Cloud Stream:基于事件(消息)驱动的微服务框架
- SpringCloudStream 构建消息驱动的微服务框架 集成kafka_http://blog.spring-cloud.io/blog/sc-stream.html
- Spring Cloud(十一)高可用的分布式配置中心 Spring Cloud Bus 消息总线集成(RabbitMQ)
- Ignite初探-ignite集成spring boot 类转换异常classCastException
- 集成springboot+thymeleaf+redis+加密框架+异常邮件提醒等技术的开源项目
- spring boot / cloud (三) 集成springfox-swagger2构建在线API文档
- 基于springboot 2.0.1.RELEASE 的Spring Cloud Eureka服务连不上注册中心
- Spring Cloud Spring Boot mybatis分布式微服务云架构(十一)Web应用的统一异常处理
- SpringCloud Stream消息驱动
- Nacos Config客户端与Spring Boot、Spring Cloud深度集成
- 记一次spring boot中MongoDB Prematurely reached end of stream的异常解决
- Spring Cloud 系列之 Stream 消息驱动(二)
- Spring-Boot--日志操作全局异常捕获消息处理☞日志控制台输出+日志文件记录
- elastic-job集成到springboot教程,和它的一个异常处理办法:Sharding item parameters '1' format error, should be int=xx,i...
- Spring Boot 2.0 快速集成整合消息中间件 Kafka