SOFABoot dependency management

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/jeikerxiao/article/details/90763845

SOFABoot dependency management

Before using SOFA middleware, we need to introduce SOFABoot dependency management.

<parent>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofaboot-dependencies</artifactId>
    <version>${sofa.boot.version}</version>
</parent>

Middleware introduced SOFA

SOFABoot using a series of suffixes to -sofa-boot-starter to mark a middleware component, if you want to use a middleware, can be added directly to the corresponding dependence.

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>
Middleware starter
SOFARPC rpc-sofa-boot-starter
SOFATracer tracer-sofa-boot-starter
SOFALookout lookout-sofa-boot-starter

Expanding component introduced SOFABoot

Spring Boot SOFABoot based health screening, isolation module, isolation class scalability.

Extended Components starter
health examination healthcheck-sofa-boot-starter
Modular isolation isle-sofa-boot-starter
Class isolation sofa-ark-springboot-starter
Extended Test test-sofa-boot-starter

SOFA introduced middleware plug-ark

SOFABoot isolation assembly provides a class SOFAArk, SOFAArk container means, a user may rely on conflict constituents packaged into packets ark plug. Runtime, ark plug-in uses a separate class loader, can and plug-ins and other business depends ark isolation, solve the problem of class conflict.

Providing SOFARPC SOFABoot official SOFATracer the ark and plug, for example into plug-in dependencies SOFARPC ark Alternatively SOFARPC starter in the application, and to isolate the application and SOFARPC indirectly dependent.

Ark plug plugin
SOFARPC rpc-sofa-boot-plugin
SOFATracer tracer-sofa-boot-plugin

Namespace introduced SOFABoot

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sofa="http://sofastack.io/schema/sofaboot"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://sofastack.io/schema/sofaboot   http://sofastack.io/schema/sofaboot.xsd"
       default-autowire="byName">
</beans>

Introducing SOFABoot Infra-dependent

To view SOFABoot directly through the browser version information SOFA middleware, only need to add the following content in Maven dependencies can:

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>infra-sofa-boot-starter</artifactId>
</dependency>

After the application starts successfully, you can enter in the browser

Start to accelerate the introduction of asynchronous dependence

The introduction of dependence

SOFABoot in v2.6.0 began offering asynchronous initialization Spring Bean capability, introduced as follows Starter you can:

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>runtime-sofa-boot-starter</artifactId>
</dependency>

Instructions

Bean asynchronous principle is to turn on the initialization method initialization (init-method) is responsible for the implementation of a separate thread Bean, so during use, in addition to introducing the above dependency management, but also the definition of Bean disposed in xml async-init="true"attribute specifies whether asynchronous execution Bean the initialization method, for example:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sofa="http://sofastack.io/schema/sofaboot"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://sofastack.io/schema/sofaboot   http://sofastack.io/schema/sofaboot.xsd"
       default-autowire="byName">
    <!-- async init  test -->
    <bean id="testBean" class="com.alipay.sofa.runtime.beans.TimeWasteBean" init-method="init" async-init="true"/>
</beans>

Configuration

SOFABoot asynchronous initialization capability provides two configuration attributes for the thread pool size designated for asynchronous execution Bean initialization method (init-method) of:

// 线程池基本大小,默认值为 CPU 核数加一
com.alipay.sofa.boot.asyncInitBeanCoreSize

// 线程池中允许的最大线程数大小,默认值为 CPU 核数加一
com.alipay.sofa.boot.asyncInitBeanMaxSize

Configuration can be provided by VM -D application.yml Spring Boot parameters or configuration files.

Guess you like

Origin blog.csdn.net/jeikerxiao/article/details/90763845