初始化队列
This commit is contained in:
parent
1eb7fd554c
commit
cbd5a98b78
|
@ -0,0 +1,5 @@
|
|||
/target/
|
||||
|
||||
/.idea/
|
||||
|
||||
|
19
pom.xml
19
pom.xml
|
@ -23,6 +23,25 @@
|
|||
<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>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.cool.mqconsumer.controller;
|
||||
|
||||
|
||||
public class IndexController {
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.cool.mqconsumer.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Message {
|
||||
private String nickname;
|
||||
private String pic;
|
||||
private String sendTime;
|
||||
private String message;
|
||||
|
||||
private String account;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.cool.mqconsumer.mq;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cool.mqconsumer.entity.Message;
|
||||
import org.springframework.amqp.core.ExchangeTypes;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class InformSmsListen {
|
||||
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(name = "queue_inform_sms"),
|
||||
exchange = @Exchange(name = "exchange_topics_inform", type = ExchangeTypes.TOPIC),
|
||||
key = {"inform.cool.sms.message"}
|
||||
))
|
||||
public void SmsConsumer(String message) {
|
||||
System.out.println(message);
|
||||
Message message1 = JSON.parseObject(message, Message.class);
|
||||
System.out.println(message1);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.cool.mqconsumer.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SmsService {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.cool.mqconsumer.util;
|
||||
|
||||
public class JsonUtils<T> {
|
||||
|
||||
|
||||
// public T jsonToJavaObject(Class<T> clazz){
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -3,4 +3,13 @@ server:
|
|||
|
||||
spring:
|
||||
application:
|
||||
name: Mq-Consumer
|
||||
name: Mq-Consumer
|
||||
rabbitmq:
|
||||
host: 119.29.254.99
|
||||
port: 5672
|
||||
username: cool
|
||||
password: cool
|
||||
virtual-host: /
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1
|
||||
|
|
Loading…
Reference in New Issue