我有两种不同的spring云服务,使用从集中式服务中接收新的配置刷新。集中调用refreshBusEndpoint.busRefresh()时
receive:RemoteApplicationEvent
originService = null
destinationService = "**"
id = "6a8d95fc-5954-4eac-b45d-ba8b34da1f9f"
timestamp = 1590192298082originService = "centralize-configuration:8888:3f31c745f983d0dd22d9988758d518a0"
destinationService = "**"
id = "7e986811-1c12-4d85-939c-054c5de9171f"
timestamp = 1590221239086问题是originService = null将导致错误
-> BusAutoConfiguration acceptRemote(RemoteApplicationEvent event)
-> !this.serviceMatcher.isFromSelf(event)
-> matcher.match(originService, serviceId)
-> AntPathMatcher.class
-> match(), doMatch() 语句停止空指针: pattern.startsWith(this.pathSeparator)
两个服务都使用:
spring-cloud.version -> Greenwich.RELEASE
spring.boot.version -> 2.1.6.RELEASE
spring.kafka.version -> 2.2.9.RELEASE 有人能用originService = null解释我的服务got事件的原因吗?
发布于 2020-05-24 08:34:54
解决方案示例:
@RequestMapping("/hello")
@RestController
public class HelloController {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private BusProperties busProperties;
@GetMapping("/test")
public String test(@RequestParam("message") String message) {
String id = busProperties.getId();
applicationContext.publishEvent(new CustomApplicationEvent(this, id, null, message));
return "Sending succeeded!";
}
}因此,我们的想法是手动提供serviceId。
资料来源:https://github.com/spring-cloud/spring-cloud-bus/issues/133#issuecomment-467755362 https://programmer.ink/think/spring-cloud-bus-custom-event-stepping.html
https://stackoverflow.com/questions/61970145
复制相似问题