5

I want to use the ZooKeeper as a service registry which replicated identical services can register themselves and clients may discover available services's url to call them. As a starter to ZooKeeper I need the basic java code for registering and discovering the services on ZooKeeper.

nourani
  • 71
  • 1
  • 6
  • As I mentioned I need the basic java code to register my web services on zookeeper and the code for clients to discover the available services. In other word I want to use ZooKeeper az a UDDI. – nourani Jan 29 '13 at 15:52
  • [This](http://zookeeper.apache.org/doc/trunk/javaExample.html) may help you – Pradeep Simha Jan 29 '13 at 15:54
  • If anybody is experienced in zookeeper I need the sample code to implement this template. – nourani Jan 29 '13 at 16:01

1 Answers1

13

Check out Curator Discovery (part of Apache Curator), a Zookeeper-based service registry written in Java.

In SOA/distributed systems, services need to find each other. i.e. a web service might need to find a caching service, etc. DNS can be used for this but it is nowhere near flexible enough for services that are constantly changing. A Service Discovery system provides a mechanism for:

  • Services to register their availability
  • Locating a single instance of a particular service
  • Notifying when the instances of a service change
Martin Serrano
  • 3,727
  • 1
  • 35
  • 48
sourcedelica
  • 23,940
  • 7
  • 66
  • 74
  • hi, your blog post [leader election using curator api](http://sourcedelica.com/blog/2013/01/) leads me here since I have some questions about this:) I couldn't comment on your blog and I found no email in your site either. Forgive me to have to ask my questions here, "I want to both leader election and server registratoin, are there any way to get some callback once the current node takes leadership (in which I can register some info in zk)?" Thanks a lot in advance. – chuchao333 Jun 20 '13 at 10:20
  • Yes, see the comment `// Do something with cluster status (log leadership change, etc)`. You can do it there. – sourcedelica Jun 20 '13 at 14:31
  • thanks a lot for your reply. That really helps. btw, do you know any real world open source projects that using curator apis to do leader election? (do you have some other chanels for me to contact you if you don't mind to share? :) ) – chuchao333 Jun 21 '13 at 06:32
  • Not off the top of my head but there are tests in the curator source that exercise that functionality. Also you can ask on the curator-users mailing list (http://curator.incubator.apache.org/mail-lists.html) – sourcedelica Jun 21 '13 at 17:34
  • sorry to bother you again, I saw your [post](http://mail-archives.apache.org/mod_mbox/zookeeper-user/201212.mbox/%3CCALEPPW9nn9bT_-qiSYPvut7z1STRuA=JA-VvkQ746_V4wtQ7hA@mail.gmail.com%3E) to zookeeper-users, what's your final solution to impl the 'fence' anyway? I came across to some articles saying that the **LeaderLatch** is not very reliable and has some bugs. From your experience, is it worth trying? Have you tested some of the edge cases? (i.e., simuate the instability of the zk ensamble) Thanks again – chuchao333 Jun 25 '13 at 02:51
  • send me a message on twitter so we can continue the conversation there. @sourcedelica. – sourcedelica Jun 25 '13 at 23:47