pulsar-client-1-2 PulsarClient constructor

Preface

As mentioned above, PulsarClient is built through chain calls, which build()are called in new PulsarClientImpl(conf), and Producer. This article understands its main structure by parsing the constructor.

// 创建PulsarClient
PulsarClient client = PulsarClient.builder()
        .serviceUrl("pulsar://localhost:6650")
        .build();
@Override
public PulsarClient build() throws PulsarClientException {
   
    
    
    // 1. 参数检验
    ...

	// 2. 构造PulsarClient
    PulsarClient client = new PulsarClientImpl(conf);
    if (conf.getServiceUrlProvider() != null) {
   
    
    
        conf.getServiceUrlProvider().initialize(client);
    }
    return client;
}

PulsarClient constructor

The constructor calls ctor1, ctor2, and ctor3 below in sequence (see comments). Among them, ctor1 created EventLoopGroup, ctor2 created ConnectionPool, ctor3 created many components, and the content is omitted.

// ctor1
public PulsarClientImpl(ClientConfigurationData conf) throws PulsarClientException {
   
    
    
    this(

Guess you like

Origin blog.csdn.net/duoyasong5907/article/details/121964470