Search in sources :

Example 1 with SubscriberOrder

use of org.apache.servicecomb.foundation.common.event.SubscriberOrder 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 SubscriberOrder

use of org.apache.servicecomb.foundation.common.event.SubscriberOrder 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 SubscriberOrder

use of org.apache.servicecomb.foundation.common.event.SubscriberOrder in project incubator-servicecomb-java-chassis by apache.

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 4 with SubscriberOrder

use of org.apache.servicecomb.foundation.common.event.SubscriberOrder in project incubator-servicecomb-java-chassis by apache.

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)

Aggregations

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