Home  >  Q&A  >  body text

网络 - java及其框架或中间件中有用到心跳机制的有哪些?

心跳机制,一般指的就是一个检测包,检测对方或者自己是否还活着?一般心跳机制在哪些地方应用啊?具体是如何使用的?比如在zookeeper中,当服务提供方的注册地址发生改变时,它是怎么通知到服务适用房的呢?平时的话,怎么知道服务的使用方是否与zookeeper有连接呢????

黄舟黄舟2761 days ago449

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:48:42

    1. The service provider and the service user are independent. The service provider cannot sense the existence of the service user, but coordinates service turnover through zookeeper

    2. When the service provider’s registration address changes, the service user has two options to detect this change

      1. Go to zookeeper every time to get the service provider list, which is obviously perceptible, but not efficient

      2. Use the watch primitive of zookeeperd to monitor a certain znode. Zookeeper will actively notify if there are changes
        In fact, to put it bluntly, one is pulling and the other is pushing

    reply
    0
  • Cancelreply