marathon 订阅事件

参考:https://mesosphere.github.io/marathon/docs/event-bus.html

启用marathon订阅功能

./bin/start --master ... --event_subscriber http_callback
需要将marathon集群都重新启动

订阅

post
http://${marathonDomain}/v2/eventSubscriptions?callbackUrl=${url}

response:

{
  "callbackUrl": "http://localhost:9292/callback",
  "clientIp": "127.0.0.1",
  "eventType": "subscribe_event"
}

接收订阅

 @RequestMapping(value = "/callback", method = RequestMethod.POST,consumes = "application/json;charset=UTF-8")
    @ResponseBody
    public String  eventSubscriber(@RequestBody String json){

        System.out.println(json);
        return "success";

    }

获取到docker发布后ip和端口

{
    "slaveId":"901048f5-3521-4625-8626-c7bb9a97f2f5-S12",
    "taskId":"notebook.f7c1d3fd-a012-11e7-ade6-ea938a30a9d9",
    "taskStatus":"TASK_RUNNING",
    "message":"",
    "appId":"/notebook",
    "host":"10.57.17.14",
    "ipAddresses":[
        {
            "ipAddress":"172.30.85.2",
            "protocol":"IPv4"
        }
    ],
    "ports":[
        31793
    ],
    "version":"2017-09-23T03:53:57.145Z",
    "eventType":"status_update_event",
    "timestamp":"2017-09-23T03:55:00.977Z"
}

你可能感兴趣的:(marathon 订阅事件)