use of com.alibaba.csp.sentinel.slots.block.BlockException in project rocketmq-externals by apache.
the class PullConsumerDemo method doSomething.
private static void doSomething(MessageExt message) {
pool.submit(() -> {
Entry entry = null;
try {
ContextUtil.enter(KEY);
entry = SphU.entry(KEY, EntryType.OUT);
// Your business logic here.
System.out.printf("[%d][%s][Success: %d] Receive New Messages: %s %n", System.currentTimeMillis(), Thread.currentThread().getName(), SUCCESS_COUNT.addAndGet(1), new String(message.getBody()));
} catch (BlockException ex) {
// Blocked.
System.out.println("Blocked: " + FAIL_COUNT.addAndGet(1));
} finally {
if (entry != null) {
entry.exit();
}
ContextUtil.exit();
}
});
}
Aggregations