Search in sources :

Example 1 with ExceptionEvent

use of org.apache.servicecomb.serviceregistry.task.event.ExceptionEvent in project incubator-servicecomb-java-chassis by apache.

the class MicroserviceWatchTask method doRun.

@Override
public void doRun() {
    // will always run watch when it is ready
    if (!needToWatch()) {
        return;
    }
    srClient.watch(microservice.getServiceId(), (event) -> {
        if (event.failed()) {
            eventBus.post(new ExceptionEvent(event.cause()));
            return;
        }
        MicroserviceInstanceChangedEvent changedEvent = event.result();
        if (isProviderInstancesChanged(changedEvent) && !serviceRegistryConfig.isWatch()) {
            return;
        }
        if (!isProviderInstancesChanged(changedEvent) && !serviceRegistryConfig.isRegistryAutoDiscovery()) {
            return;
        }
        onMicroserviceInstanceChanged(changedEvent);
    }, open -> {
        eventBus.post(new RecoveryEvent());
    }, close -> {
    });
}
Also used : ExceptionEvent(org.apache.servicecomb.serviceregistry.task.event.ExceptionEvent) MicroserviceInstanceChangedEvent(org.apache.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent) RecoveryEvent(org.apache.servicecomb.serviceregistry.task.event.RecoveryEvent)

Aggregations

MicroserviceInstanceChangedEvent (org.apache.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent)1 ExceptionEvent (org.apache.servicecomb.serviceregistry.task.event.ExceptionEvent)1 RecoveryEvent (org.apache.servicecomb.serviceregistry.task.event.RecoveryEvent)1