PC
2024-03-31 8c9ba6667b89cc0494d05b5da4355dde205b8d4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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.context.task.TaskExecutionContext;
import com.qianwen.core.notify.executor.NotifyTaskExecutorProvider;
 
@RocketMQMessageListener(consumerGroup = "task-center-notify-consumerblade-api", topic = "task-center-topic")
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/message/rocket/consumer/NotifyTaskExecuteConsumer.class */
public class NotifyTaskExecuteConsumer implements RocketMQListener<TaskExecutionContext>, RocketMQPushConsumerLifecycleListener {
    private final NotifyTaskExecutorProvider notifyTaskExecutorProvider;
 
    public NotifyTaskExecuteConsumer(final NotifyTaskExecutorProvider notifyTaskExecutorProvider) {
        this.notifyTaskExecutorProvider = notifyTaskExecutorProvider;
    }
 
    public void onMessage(TaskExecutionContext taskExecutionContext) {
        if (this.notifyTaskExecutorProvider.getExecutor().equals(taskExecutionContext.getExecutor())) {
            this.notifyTaskExecutorProvider.executeTask(taskExecutionContext);
        }
    }
 
    public void prepareStart(DefaultMQPushConsumer consumer) {
        consumer.setMaxReconsumeTimes(3);
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    }
}