org.apache.rocketmq.client.consumer.listener.ConsumeReturnType Java Examples
The following examples show how to use
org.apache.rocketmq.client.consumer.listener.ConsumeReturnType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsumerConsumeMessageHook.java From pepper-metrics with Apache License 2.0 | 6 votes |
@Override public void consumeMessageAfter(ConsumeMessageContext context) { final Long beginTime = beginTimeCache.remove(context); final String[] tags = tags(context); stats.decConc(tags); stats.observe(System.currentTimeMillis() - beginTime, tags); final Map<String, String> props = context.getProps(); final String returnType = props.getOrDefault(MixAll.CONSUME_CONTEXT_TYPE, ConsumeReturnType.FAILED.name()); if (StringUtils.equals(returnType, ConsumeReturnType.EXCEPTION.name())) { stats.error(tags); } Counter.builder(METRICS_NAME_RETURN_TYPE) .tags(Tags.of(tags).and("returnType", returnType)) .register(MetricsRegistry.getREGISTRY()) .increment(); }
Example #2
Source File: ConsumeMessageTraceHookImpl.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void consumeMessageAfter(ConsumeMessageContext context) { if (context == null || context.getMsgList() == null || context.getMsgList().isEmpty()) { return; } TraceContext subBeforeContext = (TraceContext) context.getMqTraceContext(); if (subBeforeContext.getTraceBeans() == null || subBeforeContext.getTraceBeans().size() < 1) { // If subbefore bean is null ,skip it return; } TraceContext subAfterContext = new TraceContext(); subAfterContext.setTraceType(TraceType.SubAfter);// subAfterContext.setRegionId(subBeforeContext.getRegionId());// subAfterContext.setGroupName(NamespaceUtil.withoutNamespace(subBeforeContext.getGroupName()));// subAfterContext.setRequestId(subBeforeContext.getRequestId());// subAfterContext.setSuccess(context.isSuccess());// // Caculate the cost time for processing messages int costTime = (int) ((System.currentTimeMillis() - subBeforeContext.getTimeStamp()) / context.getMsgList().size()); subAfterContext.setCostTime(costTime);// subAfterContext.setTraceBeans(subBeforeContext.getTraceBeans()); String contextType = context.getProps().get(MixAll.CONSUME_CONTEXT_TYPE); if (contextType != null) { subAfterContext.setContextCode(ConsumeReturnType.valueOf(contextType).ordinal()); } localDispatcher.append(subAfterContext); }