use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class ConcurrentlyTraceInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeMessageContext consumeMessageContext = contextThreadLocal.get();
if (consumeMessageContext == null) {
return;
}
consumeMessageContext.setSuccess(true);
consumeMessageContext.setStatus("CONSUME_SUCCESS");
hook.consumeMessageAfter(consumeMessageContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
} finally {
contextThreadLocal.remove();
}
}
use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class ConcurrentlyTraceInterceptor method doBefore.
@Override
public void doBefore(Advice advice) throws Throwable {
try {
MessageQueue messageQueue = getMessageQueue(advice.getTarget());
List<MessageExt> messageExts = getMessages(advice.getTarget());
String consumeGroup = getConsumeGroup(advice.getTarget());
if (messageExts == null || messageExts.isEmpty()) {
return;
}
ConsumeMessageContext consumeMessageContext = new ConsumeMessageContext();
consumeMessageContext.setConsumerGroup(consumeGroup);
consumeMessageContext.setMq(messageQueue);
consumeMessageContext.setMsgList(messageExts);
consumeMessageContext.setSuccess(false);
hook.consumeMessageBefore(consumeMessageContext);
contextThreadLocal.set(consumeMessageContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
}
}
Aggregations