Dubbo org.apache.dubbo.container.Main.main做了什么事

启动过程

  1. org.apache.dubbo.container.Main.main(args);通过这个类启动
会走下面的这个容器默认为 SpringContainer 
    for (Container container : containers) {
                container.start();
                logger.info("Dubbo " + container.getClass().getSimpleName() + " started!");
            }
           // 容器dubbo中的
   public class SpringContainer implements Container {

    public static final String SPRING_CONFIG = "dubbo.spring.config";
    public static final String DEFAULT_SPRING_CONFIG = "classpath*:META-INF/spring/*.xml";
    private static final Logger logger = LoggerFactory.getLogger(SpringContainer.class);
    static ClassPathXmlApplicationContext context;

    public static ClassPathXmlApplicationContext getContext() {
        return context;
    }

    @Override
    public void start() {
        String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
        if (StringUtils.isEmpty(configPath)) {
            configPath = DEFAULT_SPRING_CONFIG;
        }
        context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"), false);
        context.refresh();
        context.start();
    }
  1. 调用SpringContainer 的start方法
    @Override
    public void start() {
        String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
        if (StringUtils.isEmpty(configPath)) {
            configPath = DEFAULT_SPRING_CONFIG;
        }
        context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"), false);
        context.refresh();
        context.start();
    }

注意context = new ClassPathXmlApplicationContext(configPath.split("[,\s]+"), false);
这里传的是false是不会刷新容器的

	public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, ApplicationContext parent)
			throws BeansException {

		super(parent);
		setConfigLocations(configLocations);
		if (refresh) {
			refresh();
		}
	}
  1. 调用context.refresh();方法,正式进入Spring IOC,初始化-实例化流程
@Override
	public void refresh() throws BeansException, IllegalStateException {
		synchronized (this.startupShutdownMonitor) {
			// Prepare this context for refreshing.
			prepareRefresh();

			// Tell the subclass to refresh the internal bean factory.
			ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();

			// Prepare the bean factory for use in this context.
			prepareBeanFactory(beanFactory);

			try {
				// Allows post-processing of the bean factory in context subclasses.
				postProcessBeanFactory(beanFactory);

				// Invoke factory processors registered as beans in the context.
				invokeBeanFactoryPostProcessors(beanFactory);

				// Register bean processors that intercept bean creation.
				registerBeanPostProcessors(beanFactory);

				// Initialize message source for this context.
				initMessageSource();

				// Initialize event multicaster for this context.
				initApplicationEventMulticaster();

				// Initialize other special beans in specific context subclasses.
				onRefresh();

				// Check for listener beans and register them.
				registerListeners();

				// Instantiate all remaining (non-lazy-init) singletons.
				finishBeanFactoryInitialization(beanFactory);

				// Last step: publish corresponding event.
				finishRefresh();
			}

			catch (BeansException ex) {
			...
			}

			finally {
			.....
			}
		}
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
org.apache.dubbo.remoting.RemotingException是一个Dubbo框架提供的远程通信异常类。当在Dubbo服务之间进行远程通信时,如果出现通信中断、连接超时或其他网络相关问题,就会抛出该异常。通常,该异常会提供一些详细的错误信息,以便排查和解决问题。 要解决这个异常,你可以检查以下几个方面: 1. 网络连接是否正常:确保Dubbo服务之间的网络连接正常,并且没有任何阻塞或中断情况。可以通过检查防火墙设置、网络配置等来确认网络连接是否正常。 2. 服务提供者是否可用:确保Dubbo服务提供者正常运行并可访问。可以检查服务提供者的日志和运行状态,以确定是否存在问题。 3. 服务消费者配置是否正确:确认Dubbo服务消费者的配置是否正确,包括注册中心地址、服务接口等信息。可以检查消费者端的配置文件或代码,确保与提供者的配置一致。 4. Dubbo版本兼容性:确保Dubbo版本在服务提供者和消费者之间是兼容的。不同的Dubbo版本可能会有不同的协议和序列化方式,如果版本不兼容可能会导致通信异常。 5. 日志和错误信息:查看Dubbo服务提供者和消费者的日志,检查是否有其他错误信息或异常堆栈,以便更好地定位问题并解决。 以上是一些常见的排查步骤,希望对你解决该异常有所帮助。如果问题仍然存在,请提供更多的错误信息和具体情况,以便更好地帮助你解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值