Search in sources :

Example 1 with DefaultMQPullConsumerImpl

use of com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl 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);
}
Also used : DefaultMQPullConsumerImpl(com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl) ConsumeMessageContext(com.alibaba.rocketmq.client.hook.ConsumeMessageContext) MessageQueue(com.alibaba.rocketmq.common.message.MessageQueue) PullResult(com.alibaba.rocketmq.client.consumer.PullResult)

Aggregations

PullResult (com.alibaba.rocketmq.client.consumer.PullResult)1 ConsumeMessageContext (com.alibaba.rocketmq.client.hook.ConsumeMessageContext)1 DefaultMQPullConsumerImpl (com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl)1 MessageQueue (com.alibaba.rocketmq.common.message.MessageQueue)1