Closed paulux84 closed 5 years ago
YES,i find the same issue ,the on of the reason is the ServiceMatcher line 35 ,it always to false so that the BusAutoConfiguration line 121 this.cloudBusOutboundChannel.send(MessageBuilder.withPayload(event).build()); will never work
The service matcher try to match originService (in the spring-cloud-bus-custom-events is equal to context.getId() ) with ServiceMatcher .getServiceId() who correspond to spring.application.instance_id (if you are using eureka it's eureka.instance.instance-id)
String originService = event.getOriginService(); String serviceId = this.getServiceId();
To bypass the issue, you can inject ServiceMatcher and replace
final String myUniqueId = context.getId(); // each service instance must have a unique context ID
by
final String myUniqueId = serviceMatcher.getServiceId();
or get value from config (not tested)
@Value("${spring.application.instance_id}") private String myUniqueId ;
nb. spring.application.index is deprecated in springboot 2 and by default is unique.
You need to provide a spring.application.name
.
Even if you provide pring.application.name, I run 2 instances of app over eureka + cloud config server:
spring.application.name=my-app
Eureka config
eureka.instance.instance-id=${spring.application.name}:${random.uuid}
In ServiceMatcher
the value of originService will be my-app-1 (in instance 1) and my-app-2 (in instance2)
the value of serviceId is my-app:8080:e050422fef92f4bfd3a7c7819bd63e9b
in spring-cloud-bus-custom-events example use ApplicationContext to get the id
Monitor has issues with app names that have dashes in them
Actually, I've seen this work with app names that have dashes. can you update to Finchley.SR2 and try again?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Hi, i've updated dependendency to Finchley.SR2 but not work. I've also tried with Greenwich and Spring Boot 2.1.3 but not work. I've also tried with kafka binder but not work. I've updated the test project so you can reproduce the problem https://github.com/paulux84/spring-cloud-bus-custom-events
When creating an event try using.
@Autowired
BusProperties busProperties;
...
...
new MyCustomEvent(this, busProperties.getId(), null);
When creating an event try using.
@Autowired BusProperties busProperties; ... ... new MyCustomEvent(this, busProperties.getId(), null);
This trick do the work. Thanks
Hello, I've downloaded the following project https://github.com/tndavidson/spring-cloud-bus-custom-events and everything seems to work, but when I upgrade dependency trail to Spring Boot 2 and Finchley, the event MyCustomRemoteEvent is delivered only to the instance that has raised it. You can find in the following url the git project with the same very problem https://github.com/paulux84/spring-cloud-bus-custom-events
Thanks