Search in sources :

Example 1 with EnableExceptionPropagation

use of org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation in project java-chassis by ServiceComb.

the class ServiceRegistryListener method onCreateMicroserviceVersion.

@EnableExceptionPropagation
@SubscriberOrder(-1000)
@Subscribe
public void onCreateMicroserviceVersion(CreateMicroserviceVersionEvent event) {
    // TODO:如果失败,应该标记出错,以便删除MicroserviceVersions
    MicroserviceVersion microserviceVersion = event.getMicroserviceVersion();
    Microservice microservice = microserviceVersion.getMicroservice();
    // not shortName, to support cross app invoke
    String microserviceName = microserviceVersion.getMicroserviceName();
    MicroserviceMeta microserviceMeta = new MicroserviceMeta(scbEngine, microserviceName, true);
    microserviceMeta.setHandlerChain(scbEngine.getConsumerHandlerManager().getOrCreate(microserviceName));
    microserviceMeta.setFilterChain(scbEngine.getFilterChainsManager().findConsumerChain(microserviceName));
    MicroserviceVersions microserviceVersions = microserviceVersion.getMicroserviceVersions();
    microserviceMeta.setMicroserviceVersionsMeta(getMicroserviceVersionsMeta(microserviceVersions));
    boolean isServiceCenter = DefinitionConst.REGISTRY_APP_ID.equals(microservice.getAppId()) && DefinitionConst.REGISTRY_SERVICE_NAME.equals(microservice.getServiceName());
    // service center better to resolve the problem.
    if (!isServiceCenter) {
        for (String schemaId : microservice.getSchemas()) {
            Swagger swagger = scbEngine.getSwaggerLoader().loadSwagger(microservice, microserviceVersion.getInstances(), schemaId);
            // non java-chassis framework.
            if (swagger != null) {
                microserviceMeta.registerSchemaMeta(schemaId, swagger);
            }
        }
    }
    microserviceMeta.putExtData(CORE_MICROSERVICE_VERSION, microserviceVersion);
    microserviceVersion.getVendorExtensions().put(CORE_MICROSERVICE_META, microserviceMeta);
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) MicroserviceVersion(org.apache.servicecomb.registry.consumer.MicroserviceVersion) Swagger(io.swagger.models.Swagger) MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) EnableExceptionPropagation(org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation) SubscriberOrder(org.apache.servicecomb.foundation.common.event.SubscriberOrder) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with EnableExceptionPropagation

use of org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation in project java-chassis by ServiceComb.

the class ServiceRegistryListener method onCreateMicroservice.

@EnableExceptionPropagation
@SubscriberOrder(-1000)
@Subscribe
public void onCreateMicroservice(CreateMicroserviceEvent event) {
    MicroserviceVersions microserviceVersions = event.getMicroserviceVersions();
    microserviceVersions.getVendorExtensions().put(CORE_MICROSERVICE_VERSIONS_META, new ConsumerMicroserviceVersionsMeta(scbEngine, microserviceVersions));
}
Also used : MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) EnableExceptionPropagation(org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation) SubscriberOrder(org.apache.servicecomb.foundation.common.event.SubscriberOrder) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with EnableExceptionPropagation

use of org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation in project java-chassis by ServiceComb.

the class RestEngineSchemaListener method onCreateMicroserviceVersion.

@EnableExceptionPropagation
@Subscribe
public void onCreateMicroserviceVersion(CreateMicroserviceVersionEvent event) {
    MicroserviceVersion microserviceVersion = event.getMicroserviceVersion();
    MicroserviceMeta microserviceMeta = CoreMetaUtils.getMicroserviceMeta(microserviceVersion);
    createServicePathManager(microserviceMeta);
}
Also used : MicroserviceVersion(org.apache.servicecomb.registry.consumer.MicroserviceVersion) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) EnableExceptionPropagation(org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)3 EnableExceptionPropagation (org.apache.servicecomb.foundation.common.event.EnableExceptionPropagation)3 SubscriberOrder (org.apache.servicecomb.foundation.common.event.SubscriberOrder)2 MicroserviceVersion (org.apache.servicecomb.registry.consumer.MicroserviceVersion)2 MicroserviceVersions (org.apache.servicecomb.registry.consumer.MicroserviceVersions)2 Swagger (io.swagger.models.Swagger)1 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)1 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)1