FYI - to see an example of producer/consumer in ZooKeeper have a look at Curator (disclaimer: I'm the author of Curator): http://curator.incubator.apache.org/curator-recipes/distributed-queue.html
NOTE: It's my opinion that ZooKeeper is a bad choice for queues. Here's a post that explains why: https://cwiki.apache.org/confluence/display/CURATOR/TN4