mesosphere / marathon

Deploy and manage containers (including Docker) on top of Apache Mesos at scale.
https://mesosphere.github.io/marathon/
Apache License 2.0
4.07k stars 845 forks source link

How to get /v2/event in java #5669

Closed lijingcsu closed 6 years ago

lijingcsu commented 6 years ago

Dear fellows, I want to use /v2/event get all things real time, because the subscribe things could not get for sure sometimes。 I used org.glassfish.jersey.media.sse to get things, but I got errrors below:

InboundJaxrsResponse{context=ClientResponse{method=GET, uri=http://marathon-ip:port/v2/events, status=405, reason=Method Not Allowed}} javax.ws.rs.NotAllowedException: HTTP 405 Method Not Allowed at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1011) at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:816) at org.glassfish.jersey.client.JerseyInvocation.access$700(JerseyInvocation.java:92) at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:700) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:696) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:420) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:316) at my.springboot.SseClient.consumeEventStream(SseClient.java:36) at my.springboot.SseClient.main(SseClient.java:101) here is the code:

Client client = ClientBuilder.newBuilder().register(new SseFeature()).build(); WebTarget target = client.target(url); Response clientResponse = target.request().get(); System.out.println(clientResponse); EventInput e = null; while (true) { if (e == null || e.isClosed()) { e = target.request().get(EventInput.class); e.setChunkType("text/event-stream"); } final InboundEvent inboundEvent = e.read(); if (inboundEvent == null) { break; } else { String data = inboundEvent.readData(); // do something here - notify observers, parse json etc System.out.println(data); }

    }
    System.out.println("connection closed");

what should I do? help

marathon-bot commented 6 years ago

Hi @lijingcsu!

Thank you for your interest in Marathon! We have recently moved our issue tracking to JIRA. This issue has been automatically re-posted to JIRA. It can be found at MARATHON-7853.

Please note that, right now, you will not receive update notifications for this issue. If you wish to be notified of updates, please: