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);
|
||||
}
|
||||
}
|
|
@ -9,13 +9,11 @@
|
|||
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 定义日志文件 输入位置 -->
|
||||
<property name="log_dir" value="logs/ev_cmdb" />
|
||||
<property name="log_dir" value="logs/ev_cmdb"/>
|
||||
<!-- 日志最大的历史 30天 -->
|
||||
<property name="maxHistory" value="30"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ConsoleAppender 控制台输出日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- 对日志进行格式化 -->
|
||||
|
@ -139,13 +137,14 @@
|
|||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="java.sql.PreparedStatement" value="DEBUG" />
|
||||
<logger name="java.sql.Connection" value="DEBUG" />
|
||||
<logger name="java.sql.Statement" value="DEBUG" />
|
||||
<logger name="com.ibatis" value="DEBUG" />
|
||||
<logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />
|
||||
<logger name="java.sql.PreparedStatement" value="DEBUG"/>
|
||||
<logger name="java.sql.Connection" value="DEBUG"/>
|
||||
<logger name="java.sql.Statement" value="DEBUG"/>
|
||||
<logger name="com.ibatis" value="DEBUG"/>
|
||||
<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="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>
|
||||
|
@ -153,12 +152,12 @@
|
|||
<!-- root级别 DEBUG -->
|
||||
<root level="DEBUG">
|
||||
<!-- 控制台输出 -->
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<!-- 文件输出 -->
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="INFO" />
|
||||
<appender-ref ref="WARN" />
|
||||
<appender-ref ref="DEBUG" />
|
||||
<appender-ref ref="TRACE" />
|
||||
<appender-ref ref="ERROR"/>
|
||||
<appender-ref ref="INFO"/>
|
||||
<appender-ref ref="WARN"/>
|
||||
<appender-ref ref="DEBUG"/>
|
||||
<appender-ref ref="TRACE"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -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