@Override
	public void poll(DeploymentMessage message) {
		CuratorFramework client = getClient();
		String requestId = message.getRequestId();
		Assert.hasText(requestId, "requestId for message required");
		ResultWatcher watcher = new ResultWatcher();
		String resultPath = Paths.build(Paths.DEPLOYMENTS, Paths.RESPONSES, requestId);

		try {
			logger.trace("result path: {}", resultPath);
			client.create().creatingParentsIfNeeded().forPath(resultPath);
			client.getChildren().usingWatcher(watcher).forPath(resultPath);
			publish(message);

			long timeout = getTimeout();
			long expiry = System.currentTimeMillis() + timeout;
			synchronized (this) {
				while (watcher.getState() == State.incomplete && System.currentTimeMillis() < expiry) {
					wait(timeout);
				}
			}

			// reading the non volatile "state" and "errorDesc" outside of
			// the synchronized block is safe because they are updated
			// in a synchronized block and read after exiting the "wait"
			// thus enforcing the "happens before" semantics of the JMM
			switch (watcher.getState()) {
				case incomplete:
					throw new RuntimeTimeoutException(String.format("Request %s timed out after %d ms",
							message, expiry));
				case error:
					throw new DeploymentException(watcher.getErrorDesc());
			}
		}
		catch (InterruptedException e) {
			Thread.currentThread().interrupt();
		}
		catch (RuntimeException e) {
			throw e;
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
		finally {
			try {
				client.delete().deletingChildrenIfNeeded().forPath(resultPath);
			}
			catch (Exception e) {
				// logging this as debug; consequence is that the result
				// path isn't deleted...this is not a fatal error
				logger.debug("Exception while removing result path " + resultPath, e);
			}
		}
	}
Return the amount of time in milliseconds to wait for the message
consumer to process the deployment message. This value is 3 times
the value of the configured module deployment timeout.

@see #deploymentTimeout
@return timeout for deployment message processing
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/server/admin/deployment/zk/ZKDeploymentMessagePublisher.java