ing: 新增消息中心

This commit is contained in:
wangiegie@gmail.com 2017-11-17 09:36:04 +08:00
parent a8cb5074be
commit f9154544b8
6 changed files with 67 additions and 17 deletions

View File

@ -46,6 +46,11 @@
<version>2.0</version> <version>2.0</version>
</dependency> </dependency>
<!--mybatis-plus end --> <!--mybatis-plus end -->
<!--rabbitMQ-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -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);
}
}

View File

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

View File

@ -37,4 +37,8 @@ public interface CommonConstant {
* 按钮 * 按钮
*/ */
String BUTTON = "1"; String BUTTON = "1";
/**
* log rabbit队列名称
*/
String LOG_QUEUE = "log";
} }

View File

@ -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);
}
}

View File

@ -1,10 +1,14 @@
package com.github.pig.gateway.service.impl; package com.github.pig.gateway.service.impl;
import com.github.pig.common.constant.CommonConstant;
import com.github.pig.gateway.service.LogSendService; import com.github.pig.gateway.service.LogSendService;
import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author lengleng * @author lengleng
* @date 2017/11/16 * @date 2017/11/16
@ -13,10 +17,10 @@ import org.springframework.stereotype.Component;
@Component @Component
public class LogSendServiceImpl implements LogSendService { public class LogSendServiceImpl implements LogSendService {
@Autowired @Autowired
private AmqpTemplate amqpTemplate; private AmqpTemplate rabbitTemplate;
@Override @Override
public void send() { public void send() {
this.amqpTemplate.convertAndSend("log", "hello"); rabbitTemplate.convertAndSend(CommonConstant.LOG_QUEUE, "你好");
} }
} }