Search in sources :

Example 1 with MessageDroppedException

use of com.metamx.tranquility.tranquilizer.MessageDroppedException in project storm by apache.

the class DruidBeamBolt method process.

@Override
protected void process(final Tuple tuple) {
    Future future = tranquilizer.send((druidEventMapper.getEvent(tuple)));
    LOG.debug("Sent tuple : [{}]", tuple);
    future.addEventListener(new FutureEventListener() {

        @Override
        public void onFailure(Throwable cause) {
            if (cause instanceof MessageDroppedException) {
                collector.ack(tuple);
                LOG.debug("Tuple Dropped due to MessageDroppedException : [{}]", tuple);
                if (druidConfig.getDiscardStreamId() != null)
                    collector.emit(druidConfig.getDiscardStreamId(), new Values(tuple, System.currentTimeMillis()));
            } else {
                collector.fail(tuple);
                LOG.debug("Tuple Processing Failed : [{}]", tuple);
            }
        }

        @Override
        public void onSuccess(Object value) {
            collector.ack(tuple);
            LOG.debug("Tuple Processing Success : [{}]", tuple);
        }
    });
}
Also used : MessageDroppedException(com.metamx.tranquility.tranquilizer.MessageDroppedException) Values(org.apache.storm.tuple.Values) Future(com.twitter.util.Future) FutureEventListener(com.twitter.util.FutureEventListener)

Aggregations

MessageDroppedException (com.metamx.tranquility.tranquilizer.MessageDroppedException)1 Future (com.twitter.util.Future)1 FutureEventListener (com.twitter.util.FutureEventListener)1 Values (org.apache.storm.tuple.Values)1