config:change mq and xxl-job config
This commit is contained in:
parent
b0448f6ba0
commit
5c44ac05ec
@ -1,6 +1,7 @@
|
||||
package com.wmyun.module.system.job.demo;
|
||||
|
||||
import com.wmyun.framework.tenant.core.job.TenantJob;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -9,8 +10,8 @@ public class DemoJob {
|
||||
|
||||
@XxlJob("demoJob")
|
||||
@TenantJob
|
||||
public void execute() {
|
||||
public ReturnT<String> execute() {
|
||||
System.out.println("美滋滋");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.wmyun.module.system.mq.consumer.sms;
|
||||
import com.wmyun.module.system.mq.message.sms.SmsSendMessage;
|
||||
import com.wmyun.module.system.service.sms.SmsSendService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -16,15 +18,17 @@ import jakarta.annotation.Resource;
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RabbitListener(queues = SmsSendMessage.QUEUE)
|
||||
public class SmsSendConsumer {
|
||||
|
||||
@Resource
|
||||
private SmsSendService smsSendService;
|
||||
|
||||
@EventListener
|
||||
@Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步
|
||||
// @EventListener
|
||||
// @Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步
|
||||
@RabbitHandler
|
||||
public void onMessage(SmsSendMessage message) {
|
||||
log.info("[onMessage][消息内容({})]", message);
|
||||
log.info("[onMessage_{}][消息内容({})]", SmsSendMessage.QUEUE,message);
|
||||
smsSendService.doSendSms(message);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import com.wmyun.framework.common.core.KeyValue;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -12,7 +14,9 @@ import java.util.List;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SmsSendMessage {
|
||||
public class SmsSendMessage implements Serializable {
|
||||
|
||||
public static final String QUEUE = "SEND_MESSAGE_QUEUE";
|
||||
|
||||
/**
|
||||
* 短信日志编号
|
||||
|
@ -92,9 +92,9 @@ spring:
|
||||
# RabbitMQ 配置项,对应 RabbitProperties 配置类
|
||||
rabbitmq:
|
||||
host: 127.0.0.1 # RabbitMQ 服务的地址
|
||||
port: 5672 # RabbitMQ 服务的端口
|
||||
username: guest # RabbitMQ 服务的账号
|
||||
password: guest # RabbitMQ 服务的密码
|
||||
port: 15672 # RabbitMQ 服务的端口
|
||||
username: admin # RabbitMQ 服务的账号
|
||||
password: admin # RabbitMQ 服务的密码
|
||||
# Kafka 配置项,对应 KafkaProperties 配置类
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
|
||||
@ -103,9 +103,9 @@ spring:
|
||||
|
||||
xxl:
|
||||
job:
|
||||
enabled: false # 是否开启调度中心,默认为 true 开启
|
||||
enabled: true # 是否开启调度中心,默认为 true 开启
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
|
||||
addresses: http://127.0.0.1:8080/xxl-job-admin # 调度中心部署跟地址
|
||||
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user