gpt4 book ai didi

com.addthis.hydra.mq.ZkMessageConsumer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:35:34 26 4
gpt4 key购买 nike

本文整理了Java中com.addthis.hydra.mq.ZkMessageConsumer类的一些代码示例,展示了ZkMessageConsumer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkMessageConsumer类的具体详情如下:
包路径:com.addthis.hydra.mq.ZkMessageConsumer
类名称:ZkMessageConsumer

ZkMessageConsumer介绍

暂无

代码示例

代码示例来源:origin: addthis/hydra

public ZkMessageConsumer(CuratorFramework zkClient, String path, MessageListener<T> messageListener, final Class<T> clazz) {
  this.clazz = clazz;
  init(zkClient, path, messageListener);
}

代码示例来源:origin: addthis/hydra

private void notifyListeners(List<String> values) throws Exception {
  if (values != null && values.size() > 0) {
    for (String node : values) {
      notifyListeners(StringSerializer.deserialize(zkClient.getData().forPath(path + "/" + node)));
    }
  }
}

代码示例来源:origin: addthis/hydra

private void init(final CuratorFramework zkClient, final String path, MessageListener<T> messageListener) {
  this.zkClient = zkClient;
  this.path = path;
  addMessageListener(messageListener);
  try {
    open();
    if (zkClient.checkExists().forPath(path) == null) {
      zkClient.create().creatingParentsIfNeeded().forPath(path);
    }
    notifyListeners(zkClient.getChildren().forPath(path));
    cache = new PathChildrenCache(zkClient, path, true);
    cache.start();
    cache.getListenable().addListener(new PathChildrenCacheListener() {
      @Override
      public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
        switch (pathChildrenCacheEvent.getType()) {
          case CHILD_UPDATED:
            notifyListeners(StringSerializer.deserialize(pathChildrenCacheEvent.getData().getData()));
            break;
          default:
            log.debug("Ignored path event for node: " + pathChildrenCacheEvent);
        }
      }
    });
  } catch (Exception e) {
    log.warn("error opening client: ", e);
  }
}

代码示例来源:origin: addthis/hydra

@Override
public void connectToMQ(String hostUUID) throws IOException, TimeoutException {
  final MessageListener<HostState> hostStateListener = SpawnMQImpl.this::onMessage;
  QuiesceOnRabbitMQBlockedListener blockedListener = new QuiesceOnRabbitMQBlockedListener(spawn);
  hostStatusConsumer = new ZkMessageConsumer<>(zkClient, "/minion", hostStateListener, HostState.class);
  batchJobProducer = RabbitMessageProducer.constructAndOpen("CSBatchJob", batchBrokeAddresses,
                               batchBrokerUsername, batchBrokerPassword,
                               blockedListener);
  batchControlProducer = RabbitMessageProducer.constructAndOpen("CSBatchControl", batchBrokeAddresses,
                                 batchBrokerUsername, batchBrokerPassword,
                                 blockedListener);
  Connection connection = RabbitMQUtil.createConnection(batchBrokeAddresses, batchBrokerUsername,
                               batchBrokerPassword);
  channel = connection.createChannel();
  batchControlConsumer = new RabbitMessageConsumer<>(channel, "CSBatchControl",
                            hostUUID + Minion.batchControlQueueSuffix,
                            this, ImmutableList.of("SPAWN"),
                            ImmutableList.of(), CoreMessage.class);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com