use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class OrderlyTraceAfterInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeOrderlyStatus status = (ConsumeOrderlyStatus) advice.getParameterArray()[1];
ConsumeMessageContext consumeMessageContext = OrderlyTraceContexts.get();
if (consumeMessageContext == null || consumeMessageContext.getMsgList() == null) {
return;
}
consumeMessageContext.setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
consumeMessageContext.setStatus(status.name());
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 {
OrderlyTraceContexts.remove();
}
}
use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class PullConsumerInterceptor method doAfter.
@Override
public void doAfter(Advice advice) {
Object[] args = advice.getParameterArray();
Object result = advice.getReturnObj();
if (!checkArgs(args, result)) {
return;
}
DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) advice.getTarget();
MessageQueue mq = (MessageQueue) args[0];
PullResult pullResult = (PullResult) result;
ConsumeMessageContext consumeMessageContext = new ConsumeMessageContext();
consumeMessageContext.setConsumerGroup(consumer.groupName());
consumeMessageContext.setMq(mq);
consumeMessageContext.setMsgList(pullResult.getMsgFoundList());
consumeMessageContext.setSuccess(false);
hook.consumeMessageBefore(consumeMessageContext);
consumeMessageContext.setStatus(ConsumeConcurrentlyStatus.CONSUME_SUCCESS.toString());
consumeMessageContext.setSuccess(true);
hook.consumeMessageAfter(consumeMessageContext);
}
use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class OrderlyTraceBeforeInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeMessageContext consumeMessageContext = OrderlyTraceContexts.get();
if (consumeMessageContext == null) {
return;
}
List<MessageExt> messageExts = (List<MessageExt>) advice.getReturnObj();
if (messageExts == null || messageExts.isEmpty()) {
return;
}
consumeMessageContext.setMsgList(messageExts);
PushConsumeMessageHookImpl.getInstance().consumeMessageBefore(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);
}
}
}
use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class OrderlyTraceContextInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeMessageContext consumeMessageContext = OrderlyTraceContexts.get();
if (consumeMessageContext == null || consumeMessageContext.getMsgList() == null) {
return;
}
consumeMessageContext.setSuccess(true);
consumeMessageContext.setStatus("SUCCESS");
// 兜底,以免after没有执行(consumeMessageContext.getMsgList() != null 说明before 已经执行了)
PushConsumeMessageHookImpl.getInstance().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 {
OrderlyTraceContexts.remove();
}
}
use of com.alibaba.rocketmq.client.hook.ConsumeMessageContext in project LinkAgent by shulieTech.
the class OrderlyTraceContextInterceptor method doBefore.
@Override
public void doBefore(Advice advice) throws Throwable {
try {
MessageQueue messageQueue = getMessageQueue(advice.getTarget());
String consumeGroup = getConsumeGroup(advice.getTarget());
ConsumeMessageContext consumeMessageContext = new ConsumeMessageContext();
consumeMessageContext.setConsumerGroup(consumeGroup);
consumeMessageContext.setMq(messageQueue);
consumeMessageContext.setSuccess(false);
OrderlyTraceContexts.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