package com.qianwen.smartman.modules.notify.message.rocket.consumer;
|
|
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
import org.apache.rocketmq.spring.core.RocketMQListener;
|
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
|
import com.qianwen.core.notify.executor.NotifyExecutionContext;
|
import com.qianwen.core.notify.executor.NotifyQueueExecutorProvider;
|
|
@RocketMQMessageListener(consumerGroup = "notify-center-send-consumerblade-api", topic = "notify-center-send-topic")
|
|
public class NotifyQueueExecuteConsumer implements RocketMQListener<NotifyExecutionContext>, RocketMQPushConsumerLifecycleListener {
|
private final NotifyQueueExecutorProvider notifyQueueExecutorProvider;
|
|
public NotifyQueueExecuteConsumer(final NotifyQueueExecutorProvider notifyQueueExecutorProvider) {
|
this.notifyQueueExecutorProvider = notifyQueueExecutorProvider;
|
}
|
|
public void onMessage(NotifyExecutionContext taskExecutionContext) {
|
this.notifyQueueExecutorProvider.executeNotify(taskExecutionContext);
|
}
|
|
public void prepareStart(DefaultMQPushConsumer consumer) {
|
consumer.setMaxReconsumeTimes(3);
|
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
|
}
|
}
|