Looking for help with service lookup using Zookeeper

80 views
Skip to first unread message

Imran Hasan

unread,
Aug 11, 2017, 2:55:52 PM8/11/17
to vert.x
Hi, I'm back for some more help :)

I came across this example of service discovery with Vert.x, so I attempted to implement that in my code and use the ServiceDiscovery object to access a service from Zookeeper. Here's what I have:

ServiceDiscovery discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions()
       
.setBackendConfiguration(
             
new JsonObject()
                   
.put("connection", "10.4.4.189:2181")
                   
.put("basePath", "/services")
                   
.put("ephemeral", true)
       
));
discovery
.getRecords((JsonObject) null, result -> {
   
System.out.println("succeeded: " + result.succeeded());
   
System.out.println("result: " + result.result());
}

Right now I'm not trying to do anything other than see what services I can access, so I'm not providing any filter as to which services I'm looking for. 

I'm using log4j for logging, and it prints out the following exception:

2017-08-11T11:48:22.603-0700 o.a.c.f.i.CuratorFrameworkImpl [main-EventThread] [null] ERROR - Background exception was not retry-able or retry gave up
io.vertx.core.json.DecodeException: Failed to decode: No content to map due to end-of-input
 at [Source: ; line: 1, column: 0]
at io.vertx.core.json.Json.decodeValue(Json.java:123)
at io.vertx.core.json.JsonObject.fromJson(JsonObject.java:950)
at io.vertx.core.json.JsonObject.<init>(JsonObject.java:53)
at io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService.lambda$null$21(ZookeeperBackendService.java:275)
at io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService$$Lambda$46/1369003959.run(Unknown Source)
at io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService.runOnContextIfPossible(ZookeeperBackendService.java:183)
at io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService.lambda$null$22(ZookeeperBackendService.java:272)
at io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService$$Lambda$39/1909773120.processResult(Unknown Source)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.sendToBackgroundCallback(CuratorFrameworkImpl.java:749)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:522)
at org.apache.curator.framework.imps.GetDataBuilderImpl$3.processResult(GetDataBuilderImpl.java:257)
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:561)
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498)


I tried using the Curator Framework to test whether my Zookeeper was even working, and it is. I'm able to look up any and all of my services correctly, so it does not appear that the problem is with Zookeeper. But ideally I would be able to stick with Vert.x for this since I'm using it heavily throughout my application.

Does anybody have any experience with something similar? Am I misunderstanding something? 

Clement Escoffier

unread,
Aug 21, 2017, 4:11:53 AM8/21/17
to ve...@googlegroups.com
Hi,

I can you fill an issue on https://github.com/vert-x3/vertx-service-discovery/issues. I will have a look. The backend is expecting a json object from zookeeper, and it looks like in your case it’s not a json object at all….

Clement

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f92050df-5d76-4c95-a020-4c54b576a501%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages