RefreshEventData is package private
Question
The ConfigWatch send massage to user application with spring-event-bus ,but user application can't get the event‘s data.
the configwatch:
if (response.getValue() != null && !response.getValue().isEmpty()) {
Long newIndex = response.getConsulIndex();
if (newIndex != null && !newIndex.equals(currentIndex)) {
// don't publish the same index again, don't publish the first time (-1) so index can be primed
if (!this.consulIndexes.containsValue(newIndex) && !currentIndex.equals(-1L)) {
RefreshEventData data = new RefreshEventData(context, currentIndex, newIndex);
this.publisher.publishEvent(new RefreshEvent(this, data, data.toString()));
}
this.consulIndexes.put(context, newIndex);
}
}
my application lisenter
@EventListener
public void handle(RefreshEvent event) {
if (this.ready.get()) {
(RefreshEventData)event.getEvent();
}
}
but the RefreshEventData is a inner static class ,my application can't use it. So,who can i handle this situation?
Hey @spencergibb what was the reason for sending this event? In Spring Cloud Consul repo I can't find any class reading the event.
It's in commons I believe
So we don't want any users to operate with that event?
The event is from commons, but the data class is local to s-c-consul, but it's package private.
@dntbeSris why do you want to use that class?
I need listening the consul config changed event more nimble. Although,i can loop the refresh keys like this :
@EventListener()
public void handle(RefreshEvent event) {
if (this.ready.get()) {
Set<String> keys = this.refresh.refresh();
for(String key : keys){
if(key.startsWith(MY_CONFIG_PREFIX)){
//to do something
}
}
}
}
but spring will handle this expression when consul config value contians symbol like '{}',and will throw exception.
I need listening the consul config changed event more nimble. Although,i can loop the refresh keys like this :
@EventListener()
public void handle(RefreshEvent event) {
if (this.ready.get()) {
Set
but spring will handle this expression when consul config value contians symbol like '{}',and will throw exception.
Spencer Gibb [email protected] 于2019年7月30日周二 上午3:45写道:
The event is from commons, but the data class is local to s-c-consul, but it's package private.
@dntbeSris https://github.com/dntbeSris why do you want to use that class?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spring-cloud/spring-cloud-consul/issues/567?email_source=notifications&email_token=AD3PUXWYJFXW2FAXAXEYZHLQB5CGNA5CNFSM4HYDMET2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BZTTY#issuecomment-516135375, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3PUXQIAWHMQQXZWZ5M3KTQB5CGNANCNFSM4HYDMETQ .