mirror of https://gitee.com/maxjhandsome/pig
ing: 新增消息中心
This commit is contained in:
parent
a8cb5074be
commit
f9154544b8
|
@ -46,6 +46,11 @@
|
|||
<version>2.0</version>
|
||||
</dependency>
|
||||
<!--mybatis-plus end -->
|
||||
<!--rabbitMQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.github.pig.admin.listener;
|
||||
|
||||
import com.github.pig.common.constant.CommonConstant;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/11/17
|
||||
*/
|
||||
@Component
|
||||
@RabbitListener(queues = CommonConstant.LOG_QUEUE)
|
||||
public class LogReceiveListener {
|
||||
@RabbitHandler
|
||||
public void receive(String text) {
|
||||
System.out.println("------------------------->" + text);
|
||||
}
|
||||
}
|
|
@ -14,8 +14,6 @@
|
|||
<property name="maxHistory" value="30"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ConsoleAppender 控制台输出日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- 对日志进行格式化 -->
|
||||
|
@ -146,6 +144,7 @@
|
|||
<logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG"/>
|
||||
<logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG"/>
|
||||
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG"/>
|
||||
<logger name="org.springframework.amqp.rabbit" level="INFO"/>
|
||||
<logger name="com.github.pig.admin" level="DEBUG" additivity="true">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
|
|
|
@ -37,4 +37,8 @@ public interface CommonConstant {
|
|||
* 按钮
|
||||
*/
|
||||
String BUTTON = "1";
|
||||
/**
|
||||
* log rabbit队列名称
|
||||
*/
|
||||
String LOG_QUEUE = "log";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.github.pig.gateway.config;
|
||||
|
||||
import com.github.pig.common.constant.CommonConstant;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/11/16
|
||||
* rabbit初始化配置
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitConfig {
|
||||
@Bean
|
||||
public Queue helloQueue() {
|
||||
return new Queue(CommonConstant.LOG_QUEUE);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package com.github.pig.gateway.service.impl;
|
||||
|
||||
import com.github.pig.common.constant.CommonConstant;
|
||||
import com.github.pig.gateway.service.LogSendService;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/11/16
|
||||
|
@ -13,10 +17,10 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class LogSendServiceImpl implements LogSendService {
|
||||
@Autowired
|
||||
private AmqpTemplate amqpTemplate;
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
this.amqpTemplate.convertAndSend("log", "hello");
|
||||
rabbitTemplate.convertAndSend(CommonConstant.LOG_QUEUE, "你好");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue