xxl-job-rest
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
<module>spring-boot-drools</module>
|
||||
<module>spring-boot-xxjob</module>
|
||||
<module>spring-boot-common</module>
|
||||
<module>spring-boot-rabbitmq</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>spring-boot</artifactId>
|
||||
@@ -43,5 +44,10 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
@@ -33,17 +33,6 @@
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@@ -52,6 +41,11 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<groupId>com.wyl.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-boot-rabbitmq</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.wyl.spring.rabbitmq;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class IBSApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(IBSApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.wyl.spring.rabbitmq.conf;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.DirectExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
|
||||
|
||||
//配置direct交换机
|
||||
@Bean
|
||||
public DirectExchange directExchange() {
|
||||
return new DirectExchange("exchange.topic.shop.goodscenter.change");
|
||||
}
|
||||
|
||||
//配置direct队列
|
||||
@Bean
|
||||
public Queue directQueue() {
|
||||
return new Queue("wyl.test");
|
||||
}
|
||||
|
||||
//将direct队列绑定到交换机上
|
||||
@Bean
|
||||
public Binding directBinding(Queue directQueue, DirectExchange directExchange) {
|
||||
// 参数 1 为需要绑定的队列
|
||||
// 参数 2 为需要绑定的交换机
|
||||
// 参数 3绑定时的RoutingKey
|
||||
return BindingBuilder.bind(directQueue).to(directExchange).with("route.goodscenter.goods_basic_change");
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.wyl.spring.rabbitmq.send;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* ClassName:SendMessageImpl
|
||||
* Package:com.springboot.rabbitmq.send.service.impl
|
||||
* Description:
|
||||
*
|
||||
* @Date:2021/6/18 10:17
|
||||
* @Author:hm
|
||||
*/
|
||||
@Service("sendService")
|
||||
public class SendServiceImpl {
|
||||
|
||||
@Resource
|
||||
private AmqpTemplate amqpTemplate;
|
||||
|
||||
public void sendDirectMessage(String message) {
|
||||
/**
|
||||
* 发送direct消息
|
||||
* 参数一为交换机名称
|
||||
* 参数二为路由键名称
|
||||
* 参数三为消息
|
||||
*/
|
||||
amqpTemplate.convertAndSend("exchange.topic.shop.goodscenter.change", "route.goodscenter.goods_basic_change", message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
spring.rabbitmq.host=192.168.3.10
|
||||
spring.rabbitmq.username=asura
|
||||
spring.rabbitmq.password=asura
|
||||
spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.listener.simple.acknowledge-mode=MANUAL
|
||||
spring.rabbitmq.listener.direct.acknowledge-mode=MANUAL
|
||||
spring.rabbitmq.publisher-confirm-type=CORRELATED
|
||||
spring.rabbitmq.publisher-returns=true
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.wyl.spring.rabbitmq;
|
||||
|
||||
import com.wyl.spring.rabbitmq.send.SendServiceImpl;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
class IBSApplicationTests {
|
||||
@Autowired
|
||||
SendServiceImpl sendService;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
sendService.sendDirectMessage("123");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user