You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@rocketmq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/26 07:16:00 UTC

[jira] [Commented] (ROCKETMQ-242) mqclient can not fetch nameSrvAddr periodly

    [ https://issues.apache.org/jira/browse/ROCKETMQ-242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16101266#comment-16101266 ] 

ASF GitHub Bot commented on ROCKETMQ-242:
-----------------------------------------

GitHub user qqeasonchen opened a pull request:

    https://github.com/apache/incubator-rocketmq/pull/135

    [ROCKETMQ-242] mqclient can not fetch nameSrvAddr periodly

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/qqeasonchen/incubator-rocketmq master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rocketmq/pull/135.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #135
    
----
commit 7f4b4488ff07703d89e3a07bbe4dd7ae8d4172b4
Author: easoncchen <da...@qq.com>
Date:   2017-07-26T07:12:26Z

    [ROCKETMQ-242] mqclient can not fetch nameSrvAddr periodly

----


> mqclient can not fetch nameSrvAddr periodly
> -------------------------------------------
>
>                 Key: ROCKETMQ-242
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-242
>             Project: Apache RocketMQ
>          Issue Type: Bug
>          Components: rocketmq-client
>    Affects Versions: 4.0.0-incubating, 4.1.0-incubating
>         Environment: test and production
>            Reporter: Eason Chen
>            Assignee: Xiaorui Wang
>             Fix For: 4.2.0-incubating
>
>
> when mqclientinstance start, it getNameSrvAddr once by bellow code:
>  if (null == this.clientConfig.getNamesrvAddr()) {
>                         this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
>                     }
> but in startScheduledTask(),it will not start the schedule task if namesrvAddr is not null
> ================code=====================
> public void start() throws MQClientException {
>         synchronized (this) {
>             switch (this.serviceState) {
>                 case CREATE_JUST:
>                     this.serviceState = ServiceState.START_FAILED;
>                     // If not specified,looking address from name server
>                    *{color:red} if (null == this.clientConfig.getNamesrvAddr()) {
>                         this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
>                     }{color}*
>                     // Start request-response channel
>                     this.mQClientAPIImpl.start();
>                     // Start various schedule tasks
>                     this.startScheduledTask();
>                     // Start pull service
>                     this.pullMessageService.start();
>                     // Start rebalance service
>                     this.rebalanceService.start();
>                     // Start push service
>                     this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
>                     log.info("the client factory [{}] start OK", this.clientId);
>                     this.serviceState = ServiceState.RUNNING;
>                     break;
>                 case RUNNING:
>                     break;
>                 case SHUTDOWN_ALREADY:
>                     break;
>                 case START_FAILED:
>                     throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
>                 default:
>                     break;
>             }
>         }
>     }
> private void startScheduledTask() {
>       *{color:red} if (null == this.clientConfig.getNamesrvAddr()) {{color}*
>             this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
>                 @Override
>                 public void run() {
>                     try {
>                         MQClientInstance.this.mQClientAPIImpl.fetchNameServerAddr();
>                     } catch (Exception e) {
>                         log.error("ScheduledTask fetchNameServerAddr exception", e);
>                     }
>                 }
>             }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
>         }



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)