本文整理了Java中pl.allegro.tech.hermes.common.message.undelivered.ZookeeperUndeliveredMessageLog
类的一些代码示例,展示了ZookeeperUndeliveredMessageLog
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperUndeliveredMessageLog
类的具体详情如下:
包路径:pl.allegro.tech.hermes.common.message.undelivered.ZookeeperUndeliveredMessageLog
类名称:ZookeeperUndeliveredMessageLog
暂无
代码示例来源:origin: allegro/hermes
@Override
public UndeliveredMessageLog provide() {
return new ZookeeperUndeliveredMessageLog(zookeeper, paths, mapper);
}
代码示例来源:origin: allegro/hermes
@Override
public void persist() {
for (SubscriptionName key : lastUndeliveredMessages.keySet()) {
log(lastUndeliveredMessages.remove(key));
}
}
代码示例来源:origin: allegro/hermes
@Test
public void shouldNotAddUndeliveredMessageLogToNonExistingSubscriptionPath() {
// given
log.add(createUndeliveredMessage("unknownSubscription", "message"));
log.persist();
// when
Optional<SentMessageTrace> result = log.last(TOPIC, "unknownSubscription");
// then
assertThat(result.isPresent()).isFalse();
}
代码示例来源:origin: allegro/hermes
@Override
public Optional<SentMessageTrace> last(TopicName topicName, String subscriptionName) {
try {
String path = paths.subscriptionPath(topicName, subscriptionName, NODE_NAME);
if (exists(path)) {
return Optional.of(mapper.readValue(curator.getData().forPath(path), SentMessageTrace.class));
} else {
return Optional.empty();
}
} catch (Exception e) {
throw new InternalProcessingException(
format("Could not read latest undelivered message for topic: %s and subscription: %s .",
topicName.qualifiedName(), subscriptionName),
e);
}
}
代码示例来源:origin: allegro/hermes
@Test
public void shouldReturnAbsentIfThereAreNoUndeliveredMessagesForGivenSubscription() {
// when
Optional<SentMessageTrace> result = log.last(new TopicName("unknown", "topic"), "subscription");
// then
assertThat(result.isPresent()).isFalse();
}
代码示例来源:origin: allegro/hermes
@Test
public void shouldAddUndeliveredMessageToLog() throws Exception {
// given when
log.add(createUndeliveredMessage(SUBSCRIPTION, "message"));
log.persist();
// then
SentMessageTrace lastMessage = log.last(TOPIC, "subscription").get();
assertThat(lastMessage.getMessage()).isEqualTo("message");
}
代码示例来源:origin: allegro/hermes
private void log(SentMessageTrace messageTrace) {
try {
String undeliveredPath = paths.subscriptionPath(messageTrace.getTopicName(), messageTrace.getSubscription(), NODE_NAME);
BackgroundPathAndBytesable<?> builder = exists(undeliveredPath) ? curator.setData() : curator.create();
builder.forPath(undeliveredPath, mapper.writeValueAsBytes(messageTrace));
} catch (Exception exception) {
LOGGER.warn(
format("Could not log undelivered message for topic: %s and subscription: %s",
messageTrace.getQualifiedTopicName(),
messageTrace.getSubscription()
),
exception
);
}
}
代码示例来源:origin: allegro/hermes
@Test
public void shouldReturnLatestUndeliveredMessage() throws Exception {
// given
log.add(createUndeliveredMessage(SUBSCRIPTION, "old message"));
log.add(createUndeliveredMessage(SUBSCRIPTION, "new message"));
log.persist();
// when
SentMessageTrace lastMessage = log.last(TOPIC, "subscription").get();
// then
assertThat(lastMessage.getMessage()).isEqualTo("new message");
}
代码示例来源:origin: allegro/hermes
@Bean
UndeliveredMessageLog undeliveredMessageLog() {
return new ZookeeperUndeliveredMessageLog(storageZookeeper(), zookeeperPaths(), objectMapper);
}
内容来源于网络,如有侵权,请联系作者删除!