首页 > 编程语言 >cometd源码阅读-oort集群初始化(十三)

cometd源码阅读-oort集群初始化(十三)

时间:2022-10-23 15:13:26浏览次数:81  
标签:5.0 http demo oort 源码 SNAPSHOT cometd

说明

官方网文档:https://docs.cometd.org/current5/reference/#_java_oort

原理就是,各个服务端,定义了一个客户端,伪装成正常连接 与server建立websocket链接,并订阅指定channel消息,这个客户端就是oort,server收到消息就会转发给oort客户端,oort客户端再广播出去

这里我们主要看OortStaticConfigServlet静态初始化

基本配置

server1

  <servlet>
    <servlet-name>oort</servlet-name>
    <servlet-class>org.cometd.oort.OortStaticConfigServlet</servlet-class>
    <!--当前及诶单服务的ip端口,客户端需要链接到当前节点-->
    <init-param>
      <param-name>oort.url</param-name>
      <param-value>http://localhost:8081/cometd-demo-5.0.13-SNAPSHOT/cometd</param-value>
    </init-param>
    <!--内部维护的其他集群节点信息-->
    <init-param>
      <param-name>oort.cloud</param-name>
      <param-value>http://localhost:8082/cometd-demo-5.0.13-SNAPSHOT/cometd</param-value>
    </init-param>

<!--需要转发的channal消息-> <init-param> <param-name>oort.channels</param-name> <param-value>/chat/*,/members/*</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>

server2

  <servlet>
    <servlet-name>oort</servlet-name>
    <servlet-class>org.cometd.oort.OortStaticConfigServlet</servlet-class>
    <init-param>
      <param-name>oort.url</param-name>
      <param-value>http://localhost:8082/cometd-demo-5.0.13-SNAPSHOT/cometd</param-value>
    </init-param>
    <init-param>
      <param-name>oort.cloud</param-name>
      <param-value>http://localhost:8081/cometd-demo-5.0.13-SNAPSHOT/cometd</param-value>
    </init-param>
    <init-param>
      <param-name>oort.channels</param-name>
      <param-value>/chat/*,/members/*</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

<1>

标签:5.0,http,demo,oort,源码,SNAPSHOT,cometd
From: https://www.cnblogs.com/LQBlog/p/16818582.html

相关文章