作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.addthis.hydra.mq.ZkMessageConsumer
类的一些代码示例,展示了ZkMessageConsumer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkMessageConsumer
类的具体详情如下:
包路径:com.addthis.hydra.mq.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);
}
我是一名优秀的程序员,十分优秀!