本文整理汇总了Java中com.metamx.tranquility.tranquilizer.MessageDroppedException类的典型用法代码示例。如果您正苦于以下问题:Java MessageDroppedException类的具体用法?Java MessageDroppedException怎么用?Java MessageDroppedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageDroppedException类属于com.metamx.tranquility.tranquilizer包,在下文中一共展示了MessageDroppedException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEvents
import com.metamx.tranquility.tranquilizer.MessageDroppedException; //导入依赖的package包/类
public int sendEvents(List<Map<String, Object>> events) {
LOG.trace("Sending events: {}", events);
int sentEvents = 0;
for (final Map<String, Object> item : events) {
druidService.send(item).addEventListener(
new FutureEventListener<BoxedUnit>() {
@Override
public void onSuccess(BoxedUnit value) {
LOG.trace("Sent message: {}", item.entrySet());
}
@Override
public void onFailure(Throwable e) {
LOG.error(e.getMessage(), e);
if (e instanceof MessageDroppedException) {
LOG.warn("Dropped message: {} ", item.entrySet(), e);
} else {
LOG.error("Failed to send message: {}", item.entrySet(), e);
}
}
}
);
sentEvents++;
}
LOG.info("Total sent messages to be processed: {} ", sentEvents);
return sentEvents;
}
示例2: eventsShouldBeDropped
import com.metamx.tranquility.tranquilizer.MessageDroppedException; //导入依赖的package包/类
@Test
public void eventsShouldBeDropped() {
List<Event> events = new ArrayList<Event>();
mockSendEventsOnFailure(MessageDroppedException.Instance());
Assert.assertEquals(_tranquilitySink.sendEvents(_flumeEventParser.parse(events)), 0);
}