19 changed files with 298 additions and 21 deletions
@ -0,0 +1,44 @@ |
|||
//package com.ccsens.game.config;
|
|||
//
|
|||
//import org.springframework.core.annotation.Order;
|
|||
//
|
|||
//import javax.servlet.*;
|
|||
//import javax.servlet.annotation.WebFilter;
|
|||
//import javax.servlet.http.HttpServletResponse;
|
|||
//import java.io.IOException;
|
|||
//
|
|||
///**
|
|||
// * 实现基本的跨域请求
|
|||
// * @author linhongcun
|
|||
// *
|
|||
// */
|
|||
//@Order(1)
|
|||
//@WebFilter(filterName = "MSecurity",urlPatterns = {"**"})
|
|||
//public class CorsConfig implements Filter {
|
|||
//
|
|||
// @Override
|
|||
// public void destroy() {
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void doFilter(ServletRequest req, ServletResponse res,
|
|||
// FilterChain chain) throws IOException, ServletException {
|
|||
// HttpServletResponse response = (HttpServletResponse) res;
|
|||
// response.setHeader("Access-Control-Allow-Origin", "*");
|
|||
// response.setHeader("Access-Control-Request-Headers", "content-type,x-requested-with");
|
|||
// response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
|||
// response.setHeader("Access-Control-Max-Age", "3600");
|
|||
// response.setHeader("Access-Control-Allow-Credentials", "true");
|
|||
// response.setHeader("Access-Control-Allow-Headers", "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,token");
|
|||
// response.setHeader("Access-Control-Expose-Headers", "Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma");
|
|||
// chain.doFilter(req, res);
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void init(FilterConfig arg0) throws ServletException {
|
|||
//
|
|||
// }
|
|||
//
|
|||
//}
|
@ -1,4 +1,4 @@ |
|||
spring: |
|||
profiles: |
|||
active: dev |
|||
include: common, util-dev |
|||
active: test |
|||
include: common, util-test |
@ -0,0 +1,29 @@ |
|||
//package com.ccsens.util.mq;
|
|||
//
|
|||
//import cn.hutool.core.date.DateUtil;
|
|||
//import com.ccsens.util.config.RabbitMQConfig;
|
|||
//import com.rabbitmq.client.AMQP;
|
|||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|||
//import org.springframework.amqp.support.AmqpHeaders;
|
|||
//import org.springframework.messaging.handler.annotation.Headers;
|
|||
//import org.springframework.messaging.handler.annotation.Payload;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
//import java.util.Date;
|
|||
//import java.util.Map;
|
|||
//
|
|||
///**
|
|||
// * @description:
|
|||
// * @author: wuHuiJuan
|
|||
// * @create: 2019/12/27 15:40
|
|||
// */
|
|||
//@Component
|
|||
//public class DelayConsumer {
|
|||
// @RabbitListener(queues = RabbitMQConfig.GAME_STATUS_DELAY_SEND_QUEUE)
|
|||
// @RabbitHandler
|
|||
// public void receive(@Payload String msg, @Headers Map<String, Object> headers, AMQP.Channel channel ) {
|
|||
// System.out.println("接收到的消息:"+msg +"||" + new Date());
|
|||
// }
|
|||
//
|
|||
//}
|
@ -0,0 +1,53 @@ |
|||
//package com.ccsens.util.mq;
|
|||
//
|
|||
//import com.ccsens.util.config.RabbitMQConfig;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|||
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
///**
|
|||
// * @description:
|
|||
// * @author: wuHuiJuan
|
|||
// * @create: 2019/12/27 15:16
|
|||
// */
|
|||
//@Slf4j
|
|||
//@Component
|
|||
//public class DelayProducer {
|
|||
// @Autowired
|
|||
// private RabbitTemplate rabbitTemplate;
|
|||
//
|
|||
// //消息发送后的回调函数
|
|||
// /**
|
|||
// * 生产者回调函数:confirm确认消息投递成功
|
|||
// */
|
|||
// final RabbitTemplate.ConfirmCallback confirmCallback = (correlationData, ack, cause) -> {
|
|||
//
|
|||
// String messageId = correlationData.getId();
|
|||
// if (ack) {
|
|||
// log.info("消息投递成功,{}",messageId);
|
|||
// //进行消息记录的数据库更新
|
|||
//
|
|||
// }else{
|
|||
// log.info("消息投递失败");
|
|||
// }
|
|||
//
|
|||
// };
|
|||
//
|
|||
// /**
|
|||
// * 通过延迟消息插件发动延迟消息
|
|||
// * @param msg
|
|||
// * @param expiration
|
|||
// */
|
|||
// public void sendDelayMessage(Object msg, Long expiration){
|
|||
//
|
|||
// //绑定异步监听回调函数
|
|||
// rabbitTemplate.setConfirmCallback(confirmCallback);
|
|||
//
|
|||
// rabbitTemplate.convertAndSend(RabbitMQConfig.GAME_STATUS_DELAY_SEND_EXCHANGE,RabbitMQConfig.GAME_STATUS_DELAY_SEND_ROUTING_KEY, msg,(message)->{
|
|||
// message.getMessageProperties().setHeader("x-delay", expiration);//设置延迟时间
|
|||
// return message;
|
|||
// },new CorrelationData("123"));
|
|||
// }
|
|||
//}
|
Loading…
Reference in new issue